gradle-Android studio 添加jar后编译报错

问题描述

Android studio 添加jar后编译报错

添加了一个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 FilesJavajdk1.8.0_66injava.exe'' finished with non-zero exit value 1

解决方案

Android Studio 编译报错
android studio编译报错
Android Studio导入 setting.jar 后报错 解决方案

解决方案二:

从报错的英文上看,应该是项目是基于java1.8或者以上的,但是导的jar包是基于1.7的,所以会报错。可以修改项目的java版本到1.7再试一下。

targetCompatibility = '1.7'
sourceCompatibility = '1.7'

时间: 2024-12-24 18:52:20

gradle-Android studio 添加jar后编译报错的相关文章

eclipse add第三方jar后编译报超限错误

问题描述 eclipse add第三方jar后编译报超限错误 错误信息: Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.log4j.lf5.viewer.categoryexplorer.CategoryNodeEditor$2) that doesn't come with an associated EnclosingMethod attribute. This cla

android studio 1.5创建项目报错

问题描述 android studio 1.5创建项目报错 错误:A problem occurred configuring project ':app'. Could not download junit.jar (junit:junit:4.12) Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.jar'. > Could not GET 'https://jcenter.bin

用android studio使用百度SDK定位报错Couldn't load locSDK4d

问题描述 用android studio使用百度SDK定位报错Couldn't load locSDK4d 用eclipes开发的时候直接把文件夹复制到libs下就可以,然后引用下JAR包, 但是在android studio 做同样操作,如下 运行时候就会报错,如下 改文件名不行,求指教. 解决方案 你试试放到同一个工作空间 解决方案二: 忘记在gradle文件中修改jni目录了吧?

clr excel-CLR工程,using Microsoft.Office.Interop.Excel后编译报错

问题描述 CLR工程,using Microsoft.Office.Interop.Excel后编译报错 目的:用VS2008创建CLR窗体工程后,需要导出数据到Excel 添加microsoft excel 11.0 object library后,代码里面写入using Microsoft.Office.Interop.Excel,编译就报错,非常的怪异. 哪位大虾帮忙看看什么原因?谢谢! .selectdemo.cpp(12) : error C2872: 'Application' :

在android源码环境下编译报错: _intermediates/src/R.stamp'. Stop.

问题描述 在android源码环境下编译报错: _intermediates/src/R.stamp'. Stop. 在android源码环境下编译报错: make: *** No rule to make target out/host/linux-x86/bin/aapt', needed byout/target/common/obj/APPS/my.cloud_intermediates/src/R.stamp'. Stop. 这个错误怎么样处理?

android studio中的xml文件报错,eclipse正常不报错

问题描述 android studio中的xml文件报错,eclipse正常不报错 android:background="@drawable/one_home_page_text" 这张图片确实有,错误提示 Error:(138, 41) No resource found that matches the given name (at 'background' with value '@drawable/one_home_page_text'). eclipse中不报错,倒进stu

android ChatDemoUI3.0 Demo eclipse编译报错

问题描述 Dx warning: Ignoring InnerClasses attribute for an anonymous inner class(com.xiaomi.network.d) that doesn't come with anassociated EnclosingMethod attribute. This class was probably produced by acompiler that did not target the modern .class fil

android studio创建新项目直接报错

问题描述 android studio创建新项目直接报错 就是MainActivity里面显示找不到这个类,按alt+enter导包有提示导包但是也没用,已经导了包了,build.gradle文件里面试了导别的V7包,删掉测试导包也没效果,File->Invalidate cache/Restart也没用.这项目创建好后什么都没弄,奇怪的是我前面创建的几个项目也突然出现问题了.反而从别人那发来的项目没事,只要是自己创建的项目都一下子全部不行了.谁知道怎么解决?原因是啥? 解决方案 先clean工

studio-Android Studio中使用JUnit测试报错(ClassNotFoundException)

问题描述 Android Studio中使用JUnit测试报错(ClassNotFoundException) 在Android Studio中编写测试类public class MyAppTest extends ActivityInstrumentationTestCase2报错: Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter Caused by: java