Gradle build问题:com.android.dx.cf.iface.ParseException:错误类文件magic(cafebabe)或版本(0034.0000)

时间:2016-05-03 13:34:34

标签: android android-studio android-gradle build.gradle

我已经在我的代码库上工作了很长一段时间,没有遇到任何问题。一切都工作正常,直到几个小时后。 突然之间,构建过程不断崩溃。我甚至尝试恢复到之前的几个提交,但每次我尝试构建我的项目时,它都会崩溃。我相信我的build.gradle出了问题,但我在几天内没有做出任何改变(就像我上面提到的那样,我能够成功建立直到几个小时之后。)

我的build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.getplan"
        minSdkVersion 14
        targetSdkVersion 23
        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        generatedDensities = []
    }

    aaptOptions {
        additionalParameters "--no-version-vectors"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        incremental true
        javaMaxHeapSize "2g"
    }
}

repositories {
    mavenCentral()
    maven {
        url 'http://clojars.org/repo'
    }
}


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':library')
    compile project(':image_picker_library')
    compile project(':image_crop_supprort_library')
    compile files('libs/httpclient-4.3.6.jar')
    compile files('libs/httpcore-4.3.3.jar')
    compile files('libs/httpmime-4.1.1.jar')
    compile files('libs/HockeySDK-3.5.0.jar')
    compile files('libs/gson-2.2.4.jar')
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.google.android.gms:play-services-location:7.8.0'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.github.shell-software:fab:1.0.5'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.wdullaer:materialdatetimepicker:1.5.1'
    compile 'com.daimajia.swipelayout:library:1.2.0@aar'
    compile 'com.sothree.slidinguppanel:library:3.2.0'
    compile ('com.instabug.library:instabug:2+'){
        exclude group: 'com.google.android.gms'
    }
//    compile 'com.instabug.library:instabugsupport:1.7.4'
    compile 'com.pubnub:pubnub-android:3.7.+'
    compile 'com.mixpanel.android:mixpanel-android:4.8.0'
    compile project(':image_crop_supprort_library')
    // App Icon Badger
    compile 'me.leolin:ShortcutBadger:1.1.4@aar'
}

gradle控制台上的错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
    at com.android.dx.command.dexer.Main.processClass(Main.java:752)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
    at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
    at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:672)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:542)
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
    at com.android.dx.command.dexer.Main.run(Main.java:275)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
    at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
    at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
    at com.android.dx.command.dexer.Main.processClass(Main.java:749)
    ... 12 more

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
    at com.android.dx.command.dexer.Main.processClass(Main.java:752)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
    at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
    at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:672)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:569)
    at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
    at com.android.dx.command.dexer.Main.run(Main.java:275)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
    at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
    at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
    at com.android.dx.command.dexer.Main.processClass(Main.java:749)
    ... 12 more
2 errors; aborting


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' 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.

BUILD FAILED

Total time: 27.954 secs

我已经坚持这么久了,我遇到了类似的问题hereherehere。我似乎已经在build.gradle中实现了所有建议的更改。谁能告诉我我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

如果您使用的是Java 7而不是更高版本。

对于Android Studio,将File -> Project Structure -> SDK Location -> JDK Location更改为jdk1.7.x。对于命令行,请确保java -version输出java version "1.7.x"