当前位置:   article > 正文

【Android开发遇错】Android studio 添加jar后编译报错Error converting bytecode to dex: Cause: Dex cannot pars_android stuido error:error converting bytecode to

android stuido error:error converting bytecode to dex: cause: dex cannot par

**

添加了一个mysql-connector-java-5.1.38-bin.jar然后编译就报错了

**
错误信息如下:
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.
Error:1 error; aborting
:app:transformClassesWithDexForDebug FAILED
Error: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: org.gradle.process.internal.ExecException: Process 
'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1
  • 1
  • 2
  • 3
  • 4

原因:
出现这个现象的原因是你的jar包是基于jdk 1.8的,但当前AS(2.3.1)默认使用的jdk是1.7的。添加如下两句话,使你的项目适配JDK1.8。

解决:
这里写图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/279725
推荐阅读
相关标签
  

闽ICP备14008679号