2015-06-19 61 views
1

我有Ubuntu 15.04 64位,Scala 2.11.6和sbt 0.13.8。 我安裝了android-sdk,至少安裝了android-22ANDROID_HOMEandroid-sdk-plugin項目不知道Android類

我跟着android-sdk-plugin的 「用法」 一節,並做了以下內容:

  1. 創建一個新的目錄中的以下文件:

    • build.sbt
lazy val root = (project in file (".")). 
    settings(
    name := "Test", 
    version := "0.0.1", 
    scalaVersion := "2.11.6" 
) 
  • project/plugins.sbt
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.4.1") 
  • project/build.scala
object Build extends android.AutoBuild 
  • sbt並得到以下輸出:

    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
    [info] Loading global plugins from /home/pcn/.sbt/0.13/plugins 
    [info] Loading project definition from /home/pcn/Code/practice/test-scala-android/project 
    [info] Updating {file:/home/pcn/Code/practice/test-scala-android/project/}test-scala-android-build... 
    [info] Resolving org.fusesource.jansi#jansi;1.4 ... 
    [info] Done updating. 
    [info] Compiling 1 Scala source to /home/pcn/Code/practice/test-scala-android/project/target/scala-2.10/sbt-0.13/classes... 
    [info] Set current project to Test (in build file:/home/pcn/Code/practice/test-scala-android/) 
    > 
    
  • sbt的PROMT,鍵入gen-android android-22 com.pcn.android.test Test並得到以下輸出:

    [info] Creating project: Test 
    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
    Error: Project folder '.' is not empty. Please consider using 'android update' instead. 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/java 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test 
    Added file ./src/main/java/com/pcn/android/test/MainActivity.java 
    Created directory /home/pcn/Code/practice/test-scala-android/src/androidTest/java 
    Created directory /home/pcn/Code/practice/test-scala-android/src/androidTest/java/com/pcn/android/test 
    Added file ./src/androidTest/java/com/pcn/android/test/MainActivityTest.java 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res/values 
    Added file ./src/main/res/values/strings.xml 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res/layout 
    Added file ./src/main/res/layout/main.xml 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res/drawable-xhdpi 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res/drawable-hdpi 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res/drawable-mdpi 
    Created directory /home/pcn/Code/practice/test-scala-android/src/main/res/drawable-ldpi 
    Added file ./src/main/AndroidManifest.xml 
    Added file ./build.gradle 
    Created directory /home/pcn/Code/practice/test-scala-android/gradle/wrapper 
    [info] Creating SBT project files 
    > 
    
  • sbt的提示下,輸入compile並得到以下輸出:

    [info] Updating {file:/home/pcn/Code/practice/test-scala-android/}root... 
    [info] Resolving jline#jline;2.12.1 ... 
    [info] Done updating. 
    [info] Compiling 1 Java source to /home/pcn/Code/practice/test-scala-android/target/scala-2.11/classes... 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:3: package android.app does not exist 
    [error] android.app.Activity 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:4: package android.os does not exist 
    [error] android.os.Bundle 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:6: cannot find symbol 
    [error] symbol: class Activity 
    [error] Activity 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:10: cannot find symbol 
    [error] symbol: class Bundle 
    [error] location: class com.pcn.android.test.MainActivity 
    [error] Bundle 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:9: method does not override or implement a method from a supertype 
    [error] @Override 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:12: cannot find symbol 
    [error] symbol: variable super 
    [error] location: class com.pcn.android.test.MainActivity 
    [error] super 
    [error] /home/pcn/Code/practice/test-scala-android/src/main/java/com/pcn/android/test/MainActivity.java:13: package R does not exist 
    [error] R.layout 
    [error] (compile:compileIncremental) javac returned nonzero exit code 
    [error] Total time: 0 s, completed Jun 19, 2015 1:18:50 AM 
    > 
    
  • 正如我們所看到的,由於某種原因,它不知道約Activity和其他Android CL驢。我做錯了什麼,如何解決?我是一個完全的新手,所以如果我能得到詳細的指導,這很好。

    謝謝。

    PS:這是我~/.sbt/0.13/global.sbt的內容,如果它是相關的:

    scalacOptions ++= Seq("-deprecation", "-feature", "-optimize") 
    

    回答

    2

    做過什麼,在build.sbt混淆的AutoBuild。您可以從build.sbt中移除項目定義,或者移除AutoBuild並手動將androidBuild應用到項目中。

    相關問題