我有一个使用Java 8的功能,即通过一个Android库项目
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
当输出AAR结合Xamarin.Android,结合项目编译罚款。然而,试图用一个Xamarin.Android应用程序项目绑定项目时,我收到以下错误:
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2>COMPILETODALVIK : Uncaught translation error : com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
2> java.lang.RuntimeException: Translation has been interrupted
2> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:615)
2> at com.android.dx.command.dexer.Main.runMultiDex(Main.java:368)
2> at com.android.dx.command.dexer.Main.runDx(Main.java:289)
2> at com.android.dx.command.dexer.Main.main(Main.java:247)
2> at com.android.dx.command.Main.main(Main.java:94)
2> Caused by: java.lang.InterruptedException: Too many errors
2> at com.android.dx.command.dexer.Main.processAllFiles(Main.java:607)
2> ... 4 more
2>D:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2096,3): error : java.lang.RuntimeException : Translation has been interrupted
========== Build: 1 succeeded, 1 failed, 3 up-to-date, 0 skipped ==========
一些谷歌上搜索,它似乎与Java有关8功能。我使用的Android原生库的一些新的Java 8层的功能。难道这不支持Xamarin.Android了吗?
我没有检查我Xamarin诊断输出,这说明它是用Java 8编译:
[I:sdk]: Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_8541cfce\Android\JavaSdkDirectory found:
Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.8.0_161).
任何帮助,不胜感激!谢谢。
使用最新的Visual Studio 2019预览2.2,并添加<AndroidDexTool>d8</AndroidDexTool>
到你的Android项目,之一的csproj每个调试/发布构建
D8是由谷歌提出的新dexer并默认启用Desugar模式。