今天,我面临着一个巨大的错误,该错误使我无法在手机上运行示例项目.
当Android Studio构建项目时,它首先将以下目标显示为UP-TO-DATE:
....:demoproject:processDeBUGResources UP-TO-DATE:demoproject:generateDeBUGSources UP-TO-DATE:demoproject:compileDeBUGJava UP-TO-DATE:demoproject:proguardDeBUG UP-TO-DATE....
在构建过程中,有数十条这样的UP-TO-DATE日志语句.但是,它们始终在:demoproject:dexDeBUG处停止.对于dexDeBUG,我似乎从来没有得到UP-TO-DATE日志语句.
而是,dexDeBUG后面跟随此错误:
:demoproject:dexDeBUGwarning: Ignoring InnerClasses attribute for an anonymous inner class(com.xyz.corp.sample.project.demo.a) that doesn't come with anassociated EnclosingMethod attribute. This class was probably produced by acompiler that dID not target the modern .class file format. The recommendedsolution is to recompile the class from source, using an up-to-date compilerand without specifying any "-target" type options. The consequence of ignoringthis warning is that reflective operations on this class will incorrectlyindicate that it is *not* an inner class.
现在,有许多此类忽略InnerClasses属性错误.它们甚至出现在v4支持库中的类上,这确实令人困惑.
最后,这些错误以新的语句结尾:
UNEXPECTED top-LEVEL EXCEPTION:at com.androID.dx.command.dexer.Main.access0(Main.java:83)at com.androID.dx.cf.direct.DirectClassfile.parse0(DirectClassfile.java:472)at com.androID.dx.command.dexer.Main.main(Main.java:215)at com.androID.dx.command.dexer.Main.runMonoDex(Main.java:280)at com.androID.dx.cf.direct.ClasspathOpener.processOne(ClasspathOpener.java:166)at com.androID.dx.cf.direct.DirectClassfile.parse(DirectClassfile.java:406)at com.androID.dx.command.dexer.Main.processfileBytes(Main.java:602)at com.androID.dx.cf.direct.ClasspathOpener.process(ClasspathOpener.java:144)at com.androID.dx.cf.direct.ClasspathOpener.processArchive(ClasspathOpener.java:284)at com.androID.dx.command.dexer.Main.run(Main.java:246)at com.androID.dx.command.dexer.Main.processOne(Main.java:632)at com.androID.dx.command.Main.main(Main.java:106)...while parsing com/xyz/corp/sdk/AbcSDKConfig.class1 error; abortingError:Execution Failed for task ':demoproject:dexDeBUG'.> com.androID.IDe.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 1com.androID.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)at com.androID.dx.command.dexer.Main.processfileBytes(Main.java:673)at com.androID.dx.cf.direct.DirectClassfile.parsetoInterfacesIfNecessary(DirectClassfile.java:388)at com.androID.dx.command.dexer.Main.processAllfiles(Main.java:510)...while parsing com/xyz/corp/sdk/AbcSDKConfig.class1 error; abortingat com.androID.dx.command.dexer.Main.processClass(Main.java:704)at com.androID.dx.cf.direct.DirectClassfile.getMagic(DirectClassfile.java:251)
我已经参考了以下链接:
1. Gradle finished with non-zero exit value 1.
2. What is the “Ignoring InnerClasses attribute” warning output during compilation?.
我不确定它们是否适用于我的情况.我什至无法运行该项目.我已经将IDE更新为SDK Tools 22.0.1,并修改了build.gradle文件中的buildToolsversion标记,但无济于事.有人可以指导我如何处理此错误吗?所有帮助将不胜感激.
哦,这是我的build.gradle:
apply plugin: 'com.androID.application'androID { compileSdkVersion 22 buildToolsversion '22.0.1' packagingOptions { exclude 'meta-inf/liCENSE' exclude 'meta-inf/NOTICE' } defaultConfig { applicationID "com.xyz.corp.demo.project" minSdkVersion 10 targetSdkVersion 22 versionCode 2060200 versionname '2.6.02.00' } buildTypes { deBUG { MinifyEnabled true proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } release { MinifyEnabled true proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' applicationVariants.all { variant -> variant.outputs.each { output -> def file = output.outputfile output.outputfile = new file(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionname + ".apk")) } } } }}dependencIEs { compile filetree(dir: 'libs', include: ['*.jar']) compile 'com.androID.support:appcompat-v7:22.1.0' compile project(':xyzSDK')}
请帮忙 !!!
解决方法:
因为它正在报告:错误的类文件魔术(cafebabe)或版本(0034.0000),所以您应检查是否使用与运行时尝试使用的Java版本相同的Java版本进行编译.
如果使用的是gradle,则应在build.gradle文件中使用以下条目或类似条目:
apply plugin: 'java'sourceCompatibility = 1.7targetCompatibility = 1.7
使用此link获取更多gradle详细信息.
在AndroID Studio中,从文件->项目结构-> SDK位置->在JDK位置,您应该使用jdk 1.7,而不要在Project级别设置上进行中继.有关类似的AndroID Studio问题,请参见此link.
总结以上是内存溢出为你收集整理的Java-Android Studio意外的最高级别例外:全部内容,希望文章能够帮你解决Java-Android Studio意外的最高级别例外:所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)