错误:摇篮:执行失败的任务“:应用程序:preDexDebug” [英] Error: Gradle: execution failed for task ':app:preDexDebug'

查看:182
本文介绍了错误:摇篮:执行失败的任务“:应用程序:preDexDebug”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从另一个投影导入为库自创建罐子到我的其他项目。当我改变code在该项目中,并出口新的罐子代替了旧的,我不能运行我的应用程序了。我只得到了以下错误:

I had a self created jar from another projected imported as a library into my other project. When I changed code in that project and exported a new jar to replaced the old one I cannot run my app anymore. I only get the following error:

我曾尝试删除和添加以及添加的依赖,增加的库。似乎没有任何工作。我也做了干净的构建和重建。

I have tried removing and adding and adding as dependency, adding as library. Nothing seems to work. I have also done clean build and a rebuild.

推荐答案

我们已经看到在过去的这个问题时,我们的项目是 与Java版本的用来编译一个不同的编译库。幻数只是用来的识别类文件所以这不是这里的问题。问题是Java版本(0034.0000 ==的Java 8)。

We've seen this problem in the past when our project was compiling with a version of Java different from the one used to compile the library. The magic number is just used to identify class files so that is not the problem here. The issue is the java version (0034.0000 == Java 8).

做最简单的事情是目标Java 6,这可能需要从你的code删除新的语法。在我们的例子中,无论是项目和库是我们的,所以我们能够添加以下内容强制Java的,我们需要的版本:

The easiest thing to do is target Java 6, which may require removing newer syntax from your code. In our case, both the project and library were ours so we were able to add the following to force the version of Java that we needed:

对于Android库,添加此code的Android的扩展对象:

for android libraries, add this code to the "android" extension object:

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }
    ...
}

Java库

有关Java库,在顶级添加此code:

Java Libraries

for java libraries, add this code at the "top level":

apply plugin: 'java'

version '1.8.1'
group   'com.yourcompany.package'

sourceCompatibility = JavaVersion.VERSION_1_6   //these two lines
targetCompatibility = JavaVersion.VERSION_1_6   //are the only ones that matter

注:最后两行是唯一的这个问题,我添加了其他人只是为了显示在那里这些线路属于地,相对于你的摇篮构建文件的剩余部分

NOTE: the last two lines are the only ones that matter, I added the others just to show where those lines belong, in respect to the rest of your gradle build file.

这篇关于错误:摇篮:执行失败的任务“:应用程序:preDexDebug”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆