Error:com.android.builder.dexing.DexArchiveBuilderException

由于项目的需求,在Android studio上安装了一个插件,不幸的是同步失败.错误日志如下:

Error:com.android.builder.dexing.DexArchiveBuilderException:
Failed to process /Users/xxxxx/.gradle/caches/transforms-1/files-1.1/
realm-android-library-5.8.0.aar/70fe569130d1809121a6bf4e97697c20/jars/classes.jar`

Error:com.android.builder.dexing.DexArchiveBuilderException: 
Error while dexing io/realm/internal/OsResults.class

Error:com.android.dx.cf.code.SimException: 
invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)

Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/zhaoyanhui/.gradle/caches/transforms-1/files-1.1/realm-android-library-5.8.0.aar/70fe569130d1809121a6bf4e97697c20/jars/classes.jar

如果你的module是基于 JDK1.8 编写的 如下


image.png

那么app build.gradle android节点下中添加如下内容:

 compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
}

至此 问题解决.

Mac 环境下查看Java jdk路径及jdk版本

终端命令:
/usr/libexec/java_home -V 
需要注意的是,终端命令对大小写有严格要求, -V 大写!
jdk.png

你可能感兴趣的:(Error:com.android.builder.dexing.DexArchiveBuilderException)