gpt4 book ai didi

android-sdk-plugin 项目不知道 Android 类

转载 作者:行者123 更新时间:2023-11-29 20:41:46 25 4
gpt4 key购买 nike

我有 Ubuntu 15.04 64 位、Scala 2.11.6 和 sbt 0.13.8。我已经安装了至少 android-22 的 android-sdk,并且正确设置了 ANDROID_HOME

我遵循了 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
  1. 运行 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/)
    >
  2. sbt 的提示符下,输入 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
    >
  3. 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 类。我做错了什么,我该如何解决?我是 sbt 的完全菜鸟,所以如果我能得到详细的说明就太好了。

谢谢。

PS:这是我的~/.sbt/0.13/global.sbt的内容,以防相关:

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

最佳答案

你在 build.sbt 中所做的事情混淆了 AutoBuild。您可以从 build.sbt 中删除项目定义,或删除 AutoBuild 并手动将 androidBuild 应用于项目。

关于android-sdk-plugin 项目不知道 Android 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30930535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com