错误的类文件魔法或版本

Bad class file magic or version(错误的类文件魔法或版本)
本文介绍了错误的类文件魔法或版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我已经知道这个问题已经被经常问到并得到了答案,但我找到的答案都没有解决我的问题.

I already know that question has been already asked very often and answers, but no one of the answers i found fixed my problem.

这是错误:

Error:Gradle: Execution failed for task ':ffcommunity:preDexDebug'.
 com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    D:Android SDKsdkuild-tools20.0.0dx.bat --dex --output D:UsersReVoDocumentsIntelliJ IDEAFFCommunityffcommunityuildintermediatespre-dexeddebugananaquery-2ee85432877a057e7414910b8127805535139d5d.jar D:UsersReVoDocumentsIntelliJ IDEAFFCommunityffcommunitylibsananaquery.jar
Error Code:
    1
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    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.processClass(Main.java:665)
        at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
        at com.android.dx.command.dexer.Main.access$600(Main.java:78)
        at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
        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:596)
        at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)
    ...while parsing com/comuf/revonline/bananaquery/BananaInsert.class
    1 error; aborting

错误是bad class file magic (cafebabe) or version (0034.0000).

我在同一天多次构建和执行应用程序而没有问题,但现在每次都失败并显示此消息.

I builded and execute the application without problems many times in the same day but now this fails everytime with this message.

项目SDK为Android API 19 Platform,项目级别为1.7.

Project SDK is Android API 19 Platform and project level is 1.7.

CompileSDK 是 19 并且 buildToolsVersion 是 '20.0.0'.

CompileSDK is 19 and buildToolsVersion is '20.0.0'.

编译选项:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

dependencies 我有:

compile files('libs/bananaquery.jar')

<小时>

该库是使用 SDK Android API 19 Platform 构建的,项目级别为 1.7.


The library is build with SDK Android API 19 Platform with project level 1.7.

我的 .jar 文件位于 libs/ 文件夹中.

My .jar file is inside libs/ folder.

我使用 IntelliJ IDEA 14 Preview,可能是这个原因?使用 IntellIJ IDEA 13,它仍然停留在Gradle 同步"

I use IntelliJ IDEA 14 Preview, it could be the reason? With IntellIJ IDEA 13 it remains stuck at "Gradle sync"

编译文件可能没用,因为我也有 compile fileTree(dir: 'libs', include: ['*.jar'])

推荐答案

好吧,我的错.

在项目 SDK 部分,当您添加 Android SDK 时,您应该提供 Java SDK 并且我的所有 Android SDK 都使用 Java 8作为SDK,即使项目级别是1.7,它也会创建具有错误版本的类文件(我不知道为什么,我认为一切都是由项目级别选择的).

In the Project SDK section, when you add an Android SDK you should provide the Java SDK and all my Android SDKs uses Java 8 as SDK so it create the class files with the wrong version even if the Project level is 1.7 (i don't know why, i supposed that everything was choosed by Project level).

现在我更改了 SDK(java 版本1.x.0" 部分.)

Now i changed the SDK (the java version "1.x.0" part.)

它似乎编译得很好.

今天之前有效的原因是因为我的 SDK 是 1.8 而不是 Android API x

The reason that worked before today was because my SDK was 1.8 and not Android API x

这篇关于错误的类文件魔法或版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出现 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中获取当前风味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修复“意外元素lt;查询gt;在“清单中找到错误?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多风味库的多风味应用)
Android dependency has different version for the compile and runtime(Android 依赖在编译和运行时有不同的版本)
Transitive dependencies for local aar library(本地 aar 库的传递依赖)