在我的项目中使用jar时出错

编程入门 行业动态 更新时间:2024-10-16 22:22:19
本文介绍了在我的项目中使用jar时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Java 1.8来创建我的jar。

I use Java 1.8 to create my jar.

我可以在Java项目中使用它,但在Android项目中,我有以下错误:

I can use it in a Java project, but in an Android project, I have the following error:

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 Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.idemon.process.ProcessException: java.util.concurrent.ExecutionException: com.android.idemon.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'E:\Android-tool\JAVA\jdk1.8.0_77\bin\java.exe'' finished with non-zero exit value 1 Information:BUILD FAILED Information:Total time: 6.468 secs Information:3 errors Information:0 warnings Information:See complete output in console

推荐答案

如果是多应用程序项目中的Java库,请使用下面提到的代码在库的build.gardle文件中。

In case of a Java library in a multi-app project, use code mentioned bellow in the library's build.gardle file.

apply plugin: 'java' sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 compileJava.options.bootClasspath = "D:/android/sdk/platforms/android-23/android.jar" ... dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) ... }

您需要使用本地路径更改 compileJava.options.bootClasspath 到android.jar文件。这适用于Win10中的AS 2.2。 以获取更多参考资料,请访问 here

You will need to change compileJava.options.bootClasspath with your local path to android.jar file. This works for me in AS 2.2 on Win10. for more references please visit here

更多推荐

在我的项目中使用jar时出错

本文发布于:2023-11-17 08:46:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   jar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!