programing

잘못된 클래스 파일 매직 또는 버전

nasanasas 2020. 8. 19. 08:15
반응형

잘못된 클래스 파일 매직 또는 버전


나는 이미 자주 묻는 질문과 답변을 알고 있지만 내가 찾은 답변 중 어느 것도 내 문제를 해결하지 못했습니다.

오류입니다.

Error:Gradle: Execution failed for task ':ffcommunity:preDexDebug'.
 com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    D:\Android SDK\sdk\build-tools\20.0.0\dx.bat --dex --output D:\Users\ReVo\Documents\IntelliJ IDEA\FFCommunity\ffcommunity\build\intermediates\pre-dexed\debug\bananaquery-2ee85432877a057e7414910b8127805535139d5d.jar D:\Users\ReVo\Documents\IntelliJ IDEA\FFCommunity\ffcommunity\libs\bananaquery.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)입니다.

나는 같은 날에 여러 번 문제없이 응용 프로그램을 빌드하고 실행했지만 이제는이 메시지와 함께 매번 실패합니다.


프로젝트 SDK는 Android API 19 Platform이고 프로젝트 수준은 1.7.

CompileSDK는 19이고 buildToolsVersion은 '20.0.0'입니다.

컴파일 옵션 :

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

그리고 dependencies내가 가지고있다 :

compile files('libs/bananaquery.jar')

라이브러리는 Android API 19 Platform프로젝트 수준의 SDK 빌드 됩니다 1.7.

.jar파일은 libs/폴더 안에 있습니다.

IntelliJ IDEA 14 Preview를 사용하는데 그 이유가 될 수 있습니까? IntellIJ IDEA 13을 사용하면 "Gradle 동기화"상태가 유지됩니다.

내가 compile fileTree(dir: 'libs', include: ['*.jar'])너무 가지고 있기 때문에 컴파일 파일은 쓸모가 없을 수 있습니다.


JAVA_HOME변수가 Java 1.8로 변경되었고 순수한 Java 모듈을 내 Android 프로젝트의 종속성으로 컴파일 할 때이 오류 메시지가 나타납니다.

java 모듈의 build.gradle

apply plugin: 'java'

솔루션 # 1 : 더러움을 빠르게

JAVA_HOME등을 1.7 로 설정하여 수정했습니다 .

export JAVA_HOME=`/usr/libexec/java_home -v 1.7`

솔루션 # 2 : 컴파일러 버전 변경 :

build.gradle에서이 특정 모듈에 대해 다시 1.7로 변경합니다.

apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7

좋아, 내 잘못이야.

프로젝트 SDK 섹션에서를 추가 할 때를 Android SDK제공해야 Java SDK하며 모든 Android SDK는 Java 8 을 SDK로 사용하므로 프로젝트 수준이 1.7(이유를 모르겠습니다. 모든 것이 프로젝트 수준에서 선택되었습니다.)

이제 SDK ( java version "1.x.0"부분)를 변경했습니다 .

enter image description here

and it seems to compile fine.

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


In case people find @Marco Acierno's answer to be a bit unclear, the solution is to ensure you're building with Java 7 and not a higher version.

For Android Studio, change File -> Project Structure -> SDK Location -> JDK Location to jdk1.7.x. For the command line, ensure java -version outputs java version "1.7.x".


Setting JAVA_HOME back to 1.7 worked for me.


change all your module java version to java 1.7 in every build.grade file.

in plugin which is library and application

compileOptions{
    sourceCompatibility=JavaVersion.VERSION_1_7
    targetCompatibility=JavaVersion.VERSION_1_7
}

and in java

sourceCompatibility= 1.7
targetCompatibility= 1.7

This problem occurs when you use a .jar file that is not using any feature of Java 6 or higher but was built using Java 6 or higher.

If you built that .jar file then you don't need to change anything in Gradle or ProGuardor Compiler Version. The solution is very simple, just build that .jar file again but using Java 5 or less.

More details.


I had a similar issue, i solved it by upgrading my proguard. get your proguard version by this command

java -jar ~/android-sdks/tools/proguard/lib/proguard.jar 

get the latest progaurd.jar file from here (http://proguard.sourceforge.net)

replace the existing android-sdks/tools/proguard/lib/proguard.jar with new .jar file.

Hopefully this should help you. If u using java 8 then you should upgrade to proguard 5.x coz proguard 4.x does not support java 8.


had a similar issue when i tried to add a self made library from netbeans to android studio. setting the source- and target compatibility in android studio and source/binary format in netbeans (both!) to java 1.7 solved the problem.

in android studio:

Project Structure -> Modules/App -> Propreties -> Source- and Target to 1.7

in netbeans:

File -> Project Properties -> Sources -> Source/Binary Format to 1.7

then clean and build your netbeans projekt and copy the .jar from "NBProj/dist" to "app/libs"


share the solution of the case if only Java8 installed, just set Java compiler level to 1.7 and then rebuild the project should be OK.

참고URL : https://stackoverflow.com/questions/24662801/bad-class-file-magic-or-version

반응형