android studio在签名打release包时,打包不成功,报了以下错误:
Caused by: com.android.tools.r8.utils.AbortException
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
错误图片
经过排查错误,发现这是因为较新的java8语言特性导致的,可以通过在项目Module的build.gradle文件中添加以下代码解决:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
添加了上面代码后,重新编译打包成功。
网友评论