无法修复" ParseException的:糟糕的类文件魔术(cafebabe)或版本(0034.0000)QUOT; (在transformClassesWithDexForDebug步的gradle开始瓦特/错误) [英] Unable to fix "ParseException: bad class file magic (cafebabe) or version (0034.0000)" (Began w/ error at transformClassesWithDexForDebug gradle step)

查看:194
本文介绍了无法修复" ParseException的:糟糕的类文件魔术(cafebabe)或版本(0034.0000)QUOT; (在transformClassesWithDexForDebug步的gradle开始瓦特/错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近进口从我的AWS应用程序中的罐子,其中包含所有我将要在我的Andr​​oid应用程序引用的对象。只要是在我的Andr​​oid Studio项目,并通过摇篮勾搭上了,错误显示并不会消失,直到我清除我的进口罐子和重建一切。

I recently imported a jar from my AWS application that contains all the objects I am going to be referencing on my Android application. As soon as that is in my Android Studio project and hooked up via Gradle, the error shows up and doesn't go away until I clear out my imported jar and rebuild everything.

我读了什么:

此错误可能是合法的。当一个Android应用超过65000名的方法会发生这种情况。我的应用程序可能会很大,但我会感到惊讶,如果所有我进口总额超过了图书馆....我不会排除这种可能,但是这是一个很大的方法。从我所看到,十次有九次,这是一个配置错误。我看书上说的第一对夫妇的文章,以使Proguard的删除所有未使用的方法,但没有帮助。

This error can be legitimate. This can happen when an Android application surpasses 65k method names. My application may be big, but I would be amazed if all the libraries I imported totaled over that.... I won't rule it out, but that is a lot of methods. From what I saw, nine times out of ten, this was a configuration bug. The first couple articles I read said to enable Proguard to remove all unused methods, but that didn't help.

我的配置:

我有我的Andr​​oid Studio环境中的一切设置为运行Java 7:

I have everything on my Android Studio environment set to run Java 7:


  • 项目字节code版本:1.7

  • JDK位置:C:\\ Program Files文件\\的Java \\ jdk1.7.0_45

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.maveric.helloworld"
        minSdkVersion 15
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:4.2.42'
    compile 'com.android.support:appcompat-v7:20.0.0'
    compile 'org.apache.commons:commons-io:1.3.2'
    compile 'com.cedarsoftware:json-io:4.3.0'
}

我已经花了近5小时,试图对SO每一个解决方案,而且还没有运气的单个位和他们任何人。

I have spent the last 5 hours trying every single solution on SO, and haven't had a single bit of luck with any of them.

推荐答案

6个多小时努力解决方案后,一挂奥列格我的意见最终导致我这个问题的真正原因。

After over 6 hours of trying solutions, the one Oleg linked me in the comments finally led me to the real cause of the problem.

问题的简要说明可以发现这里,但我会尽量解释一切如何看待我的系统上

The brief explanation of the issue can be found HERE, but I will try to explain how everything looked on my system:

此错误首次出现了我,当我进口的,那是我主要的Java项目,该项目在Eclipse托管的一部分jar文件。

This error first showed up for me when I imported a jar file that was part of my main Java project, which was hosted in Eclipse.

这个错误首先捅到用户的方式是通过邮件选项卡,其中摇篮走过的每一个任务。它崩溃的任务是

The way this error first pokes up to the user is through the Messages tab where Gradle walks through each of its tasks. The task that it crashes on is

:app:transformClassesWithDexForDebug

问题是摇篮消息窗口只是说了任务失败,然后给出了一个非描述性错误消息说

The problem is the Gradle Messages window just says the task failed and then gives a non-descriptive error message saying

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 1

为了获得更好的视野,你需要在摇篮控制台视图去看看。在终端查看文本告诉你这一点:

In order to get a better view, you need to go look at the Gradle Console view. The text in the terminal view tells you this:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

滚动起来有点表明堆栈跟踪通过就好了出来,尽管这最初的消息暗示,应该有添加了对调试的其他标志。堆栈跟踪的顶部这样说:

Scrolling up a little bit shows that the stacktrace came through just fine, even though this initial message hints that there should be additional flags added for debugging. The top of the stacktrace says this:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)

但即使这样,也帮助不大。它是什么想告诉你(很差我要补充)是,它是在寻找类与不支持一个Java版本编译的。就我而言,版本(0034)是52六角重新presentation这意味着Java的Andr​​oid版8不支持Java 8,所以终止构建。

But even that doesn't help very much. What it is trying to tell you (very poorly I have to add) is that the class it is looking at was compiled with a Java version that is not supported. In my case, version (0034) was the hex representation of 52 which means Java 8. Android doesn't support Java 8, so it terminates the build.

解决的办法是回到我的Eclipse项目,并导出与编译器设置为1.7版本的jar文件,现在一切都重新启动和运行。我希望这有助于!

The solution was to go back to my Eclipse project and export the jar file with the compiler set to version 1.7 and now everything is up and running again. I hope this helps!

这篇关于无法修复" ParseException的:糟糕的类文件魔术(cafebabe)或版本(0034.0000)QUOT; (在transformClassesWithDexForDebug步的gradle开始瓦特/错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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