This is caused by library dependencies that have been compiled using Java 8 or above
来源:互联网 发布:网络视频管理服务器 编辑:程序博客网 时间:2024/06/06 20:11
错误信息:
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.
上面信息意思是,你使用了Java 8 或更高版本编译,你如果使用’java’ gradle 插件,应该加入
targetCompatibility = '1.7'sourceCompatibility = '1.7'
原因分析:
如果仅仅使用java8 ,要为您的项目启用 Java 8 语言功能和 Jack,请在module的 build.gradle 文件中输入以下内容:
android { ... defaultConfig { ... jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}
在Android Studio中使用 Java 8时,Jack 仅在 Android Studio 2.1 和更高版本上才受支持。要在 Android 的较早版本中测试 Lambda 表达式、方法引用和类型注解,请前往您的 build.gradle 文件,将 compileSdkVersion 和 targetSdkVersion 设置为 23 或更低。您仍需要启用 Jack 工具链以使用这些 Java 8 功能。
注意:如果没有配置Jack 工具链(如下的代码),就会报上面的错误
jackOptions { enabled true }
使用retrolambda插件,可以在 Java 5/6/7中使用lambda,它的配置如下,
注意:这里不需要配置Jack 工具链(如下的代码),只需要启用 Java 8 语言功能
apply plugin: 'me.tatarka.retrolambda'android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}
解决:
知道了原因,大家就可以根据各自的情况解决问题,我记录一下,我这边的解决方法:
在一个library的module中build.gradle,只配置了
android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}
后来把这个配置删除了,就可以了
参考:
使用 Java 8 语言功能
Dagger 2.10-rc1 won’t compile in Android
Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code.
Android: Dex cannot parse version 52 byte code
Error:Jack is required to support java 8 language features [duplicate]
如何在android module中使用Java 8的新特性,比如Lambda?
- 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
- 使用C#及Office组件将DataTable对象保存为Excel文件
- LeetCode--Group Anagrams
- 记一次CSS引发的小Bug
- java架构师、集群、高可用、高可扩展、高性能
- PLSQL Developer64位安装配置
- This is caused by library dependencies that have been compiled using Java 8 or above
- Job for network.service failed
- java导入excel数据内容存入数据库
- git commit的信息如何修改,如何退出修改
- 浅谈MVC、MVP、MVVM架构模式的区别和联系
- 静态对象的初始化
- 2017-Spring-Summit大会-(中国首届)参会后感受和一些思考
- 我眼中的RestFul API是怎样的
- 算法学习-2.4子序列的和