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

残念ながら、処理された renderscript ソースのファイルをcom.android.builder.core.AndroidBuilder生成しなくなったようです。で使用するためにバイパスすると、.d生成されたファイルを決定するために必要なファイルが復元される可能性があります。しかし、それは の将来のバージョンの解決策になります。AndroidBuildercom.android.sdklib.build.RenderScriptProcessorsbt-android.dsbt-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 に答える