This is caused by library dependencies that have been compiled using Java 8 or above.
来源:互联网 发布:python 打开html文件 编辑:程序博客网 时间:2024/05/20 22:28
1.错误现象
在用android studio编译项目的时候提示错误:
Error:Error converting bytecode to dex:Cause: Dex cannot parse version 52 byte code.This is caused by library dependencies that have been compiled using Java 8 or above.If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7'sourceCompatibility = '1.7'to that submodule's build.gradle file....while parsing android/support/led/app/LedHalService.classError:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --output /opt/FriendlyARM/LED_Drivers0420/Topic10/LedHAL/app/build/intermediates/pre-dexed/debug/LedHalService_c20efee379c8b345d133fb96ed6915725bb338c1.jar /opt/FriendlyARM/LED_Drivers0420/Topic10/LedHAL/app/libs/LedHalService.jar}
2.问题分析和解决
出现这个问题是因为库的编译器版本和当前项目编译器版本不对应,导致编译出来的目标文件不能链接在一起。解决方法就是让android studio适配这个版本的编译器,按照错误的提示在gradle build添加:
targetCompatibility = '1.7'sourceCompatibility = '1.7'然而再次编译的时候依然提示错误。
看来android studio不能自动适配这个java编译器版本不对的问题,那就必须更改linux默认的JAVA编译器版本,输入两个命令即可更改:
root@g450:/opt/android-studio/jre/bin# update-alternatives --config java有 2 个候选项可用于替换 java (提供 /usr/bin/java)。 选择 路径 优先级 状态------------------------------------------------------------ 0 /usr/lib/jvm/jdk1.8.0_74/bin/java 300 自动模式* 1 /usr/lib/jvm/jdk1.6.0_43/bin/java 1 手动模式 2 /usr/lib/jvm/jdk1.8.0_74/bin/java 300 手动模式要维持当前值[*]请按回车键,或者键入选择的编号:1root@g450:/opt/android-studio/jre/bin# update-alternatives --config javac有 2 个候选项可用于替换 javac (提供 /usr/bin/javac)。 选择 路径 优先级 状态------------------------------------------------------------ 0 /usr/lib/jvm/jdk1.8.0_74/bin/javac 300 自动模式* 1 /usr/lib/jvm/jdk1.6.0_43/bin/javac 1 手动模式 2 /usr/lib/jvm/jdk1.8.0_74/bin/javac 300 手动模式要维持当前值[*]请按回车键,或者键入选择的编号:1
注意:只更改java的版本还是解决不了问题,必须同时更改javac的版本才可以。
阅读全文
0 0
- This is caused by library dependencies that have been compiled using Java 8 or above.
- This is caused by library dependencies that have been compiled using Java 8 or above.
- This is caused by library dependencies that have been compiled using Java 8 or above.
- This is caused by library dependencies that have been compiled using Java 8 or above
- 问题:caused by library dependencies that have been compiled using Java 8 or above
- shiro中出现Caused by: java.lang.IllegalStateException: Configuration error: No realms have been config
- Caused by: java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required
- Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this respo
- Caused by: java.lang.IllegalStateException: This app has been built with an incorrect configuration.
- 1.The Struts dispatcher cannot be found. This is usually caused by using Struts
- The Struts dispatcher cannot be found. This is usually caused by using Struts
- struts2 配置出现错误信息This is usually caused by using Struts tags without the associated filter
- Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associat
- .The Struts dispatcher cannot be found. This is usually caused by using Struts
- The Struts dispatcher cannot be found. This is usually caused by using Struts
- This is usually caused by using Struts tags without the associated filter
- The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the...
- The Struts dispatcher cannot be found. This is usually caused by using Struts t
- git和github学习笔记
- JAVA中获取当前系统时间
- 字符串比较
- [TensorFlow]生成对抗网络(GAN)介绍与实践
- 单字节对齐
- This is caused by library dependencies that have been compiled using Java 8 or above.
- java垃圾收集器与内存分配策略(1)
- VS2010安装失败总结
- redis中的主从同步与集群管理
- Python 引用 :可变类型和不可变类型
- Properties转换成Map
- jquery 跨域请求 报错:(原因:CORS 头缺少 'Access-Control-Allow-Origin')
- Android apk签名方法介绍
- Truncated class file description The server encountered aninternal error that prevented it from fulf