问题描述
阅读其他类似的问题后,我仍然没有找到一个解决方案。我得到这抱怨包含我公司开发的库罐子,与Java 1.7编译以下堆栈跟踪:
After reading other similar questions, I still couldn't find a solution for this. I get the following stack trace which complains about a jar containing a library that I developed, compiled with Java 1.7:
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:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
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:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
...while parsing build/classes/main/com/utils/helpers/DateTimeAdapter.class
我有编译器的水平无论是在Android的Studio和Eclipse设置为Java 7中的build.gradle文件中添加sourceCompatibility和targetCompatibility没有解决这个问题。到JDK的路径也正确地在这两个IDE的设置。
I have the compiler level set to java 7 both in Android Studio and Eclipse and adding sourceCompatibility and targetCompatibility in the build.gradle file did not solve this problem. The path to the JDK is also correctly set in both IDE's.
我发现0034是Java 8个十六进制,但它甚至没有安装在我的机器。
I found out that 0034 is hexadecimal for Java 8, but it's not even installed in my machine.
我也试过编辑proguard.bat,建议在此thread,没有运气。
I also tried editing proguard.bat, suggested in this thread, with no luck.
有没有人对此有什么看法吗?
Does anyone have any thoughts on this?
推荐答案
尽管类是使用Java 7的编译和命令的javap -verbose
这么说,我的时候Android Studio中打开.class文件,它表现出的反编译的.class文件,字节code版本:在屏幕上方52.0(8 Java的)
Even though the class was compiled with Java 7 and the command javap -verbose
said so, when I opened the .class file in Android Studio, it showed Decompiled .class file, bytecode version: 52.0 (Java 8) on the top of the screen.
在最后,删除和重新编译罐子没有获得成功。
In the end, deleting and compiling the jar again did the trick.
这篇关于坏类cafebabe或版本0034的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!