Android的工作室意外顶级例外: [英] Android Studio UNEXPECTED TOP-LEVEL EXCEPTION:
问题描述
今天,我面临着一个巨大的错误,这并不让我我的手机上运行示例项目。
Today I am faced with a massive error that doesn't let me run a sample project on my phone.
在Android的工作室正在建设的项目,它首先显示了以下目标为 UP-TO-DATE
:
When Android Studio is building the project, it first shows the following targets as 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
日志报表。
There are dozens of these UP-TO-DATE
log statements during the build process. However, they always halt at :demoproject:dexDebug
. For dexDebug
, I never seem to get an UP-TO-DATE
log statement.
相反, dexDebug
后跟此错误:
:demoproject:dexDebug
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.xyz.corp.sample.project.demo.a) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
现在有几十个,这些忽略InnerClasses属性
错误。他们甚至出现在V4支持库,这是真正令人困惑的类。
Now there are dozens of these Ignoring InnerClasses attribute
errors. They even occur for classes in the v4 support library, which is truly perplexing.
最后,这些错误有一个新的语句结尾:
Finally, these errors end with a new statement:
UNEXPECTED TOP-LEVEL EXCEPTION:
at com.android.dx.command.dexer.Main.access$300(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$1.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.class
1 error; aborting
Error: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 1
com.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.class
1 error; aborting
at com.android.dx.command.dexer.Main.processClass(Main.java:704)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
我已经咨询了以下链接:
I have already consulted the following links:
2 什么是忽略InnerClasses属性编译时报警输出? 。
我不知道它们适用于我的情况。我甚至能的运行的项目。我已经更新了我的IDE SDK工具22.0.1在我的的build.gradle
文件修改 buildToolsVersion
标签,但无济于事。是否有人可以指导我如何处理这个问题?所有帮助将AP preciated。
I'm not sure they apply to my situation. I'm not even able to run the project. I've updated my IDE to SDK Tools 22.0.1 and modified the buildToolsVersion
tag in my build.gradle
file, but to no avail. Can someone please guide me how to deal with this error ? All help will be appreciated.
呵呵,这是我的的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')
}
请帮助!!!
推荐答案
意外顶级EXCEPTION
意味着你得到包含两次任何。 JAR
。
UNEXPECTED TOP-LEVEL EXCEPTION
means that you are getting included twice any .jar
.
由于@Akhil说你应该排除支持-V4
,因为我想这是主要的问题,但是如果@Akhil回答没有帮助你尝试一下这个方法。
As @Akhil said you should exclude support-v4
because I guess it's the main problem, but if @Akhil answer didn't help you try it out this method.
compile (':xyzSDK') {
exclude group: 'com.android.support', module: 'support-v4'
}
您是否尝试过删除这一行?
Have you tried to delete this line?
compile 'com.android.support:appcompat-v7:22.1.0'
也许:xyzSDK
媒体链接有应用程序兼容性-V7:22 +
..
我给你那里通过@CommonsWare很好的答案来作报告的gradle看看有什么问题。
I give you there a good answer by @CommonsWare to make a gradle report to see what's the problem.
我正在为你的答案,所以如果我找到的东西interessant我将更新我的答案。
I'm working for your answer, so if I find something interessant I'll be updating my answer.
一旦你做到了这一点您必须 构建 - >重建项目
Once you've done this you must Build -> Rebuild project
我在@丹的回答也看到了......我让你有一个可能的<一个href=\"http://stackoverflow.com/questions/24741948/wrong-java-compiler-when-including-a-java-module-as-dependency-in-android-studio\">answer.
Also as I saw on @dan answer... I let you there a possible answer.
而不是 1.7
丹说尝试:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
否则,你可以检查一下手动将文件&gt;项目结构
或<大骨节病>控制骨节病> + <大骨节病>替代骨节病> + <大骨节病>移骨节病> + <大骨节病>取值骨节病>,然后在 JDK位置
看你有什么用,如果你使用的是1.8更改为1.7的SDK路径
Otherwise you can check it manually going to File > Project Structure
or Ctrl+Alt+Shift+S and then on the JDK location
see what are you using and if you are using 1.8 change to your 1.7 SDK path
和BTW我认为,我读过你问我,如果你可以使用 JAVA 8
为Android而不是 JAVA 7
如果我没有错....是的,你可以使用 JDK 8
,但前提是你也可以使用 gradle这个-retrolamba
像这样<一说href=\"http://stackoverflow.com/questions/23318109/is-it-possible-to-use-java-8-for-android-development\">question..
And btw I think that I've read that you have asked if you could use JAVA 8
for Android instead of JAVA 7
if i'm not wrong.... and yes you could use JDK 8
, but only if you also use gradle-retrolamba
like says on this question..
这篇关于Android的工作室意外顶级例外:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!