0

It seems that sbt-android is ignoring the presence of the RenderScript files and is not generating the ScriptC_xxx java classes that are normally generated by gradle builds/Android Studio [UPDATE: this is false, se the update note below]. Because of this issue, the sbt-android build is failing because to use the scripts we need to reference the generated ScriptC_xxx classes, which gives the following error when building:

[error] apackage/YYYClass.java:55: cannot find symbol
[error]   symbol:   class ScriptC_xxx
[error]   location: class apackage.YYYClass
[error]         ScriptC_xxx xxxScript = new ScriptC_xxx(rs);

The generated .sbt file from the existing project (which compiles normally by gradle) has the apparent necessary configuration for RenderScript, generated from the build.gradle file:

rsTargetApi in Android := "18",
rsSupportMode in Android := rsSupportMode.value || true

What I am missing to be able to compile renderscript-containing android projects with sbt-android ?

UPDATE: I realized that the java classes for the scripts are being generated correctly, but somehow the classes that use those generated classes cannot find them, so maybe I have a classpath configuration problem.

This is the current file structure:

./asubmodule/src/main/rs/xxx.rs (using package declaration #pragma rs java_package_name(apackage.scripts))

./asubmodle/src/main/java/apackage/YYYClass.java

./asubmodule/target/android/generated/source/android/support/v7/appcompat/R.java

./asubmodule/target/android/generated/source/apackage/scripts/ScriptC_xxx.java

4

1 回答 1

2

不幸的是,它似乎com.android.builder.core.AndroidBuilder不再.d为已处理的渲染脚本源生成文件。绕过AndroidBuilder使用com.android.sdklib.build.RenderScriptProcessorinsbt-android可以恢复.d确定生成文件所需的文件。但这将是未来版本的sbt-android.

要暂时解决您的问题,您可以将以下内容添加到您的build.sbt

sourceGenerators in Compile += Def.task {
  implicit output = outputLayout.value
  val layout = projectLayout.value
  (layout.generatedSrc ** "ScriptC_*.java").get ++ (layout.generatedSrc ** "*BitCode.java").get
}.taskValue

由于听起来您正在使用sbt-android-gradle,您可以创建一个新文件build.sbt并将上述内容放入(不要编辑00-gradle-generated.sbt

更新:这将在sbt-android https://github.com/scala-android/sbt-android/commit/ec09a55233aabd50e7df0085b10c567e38b616d3的下一版本中修复

于 2016-08-05T16:19:39.090 回答