机器人工作室的错误 - 意外的顶级例外: [英] Android Studio error - UNEXPECTED TOP-LEVEL EXCEPTION:

查看:183
本文介绍了机器人工作室的错误 - 意外的顶级例外:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我面对的是一个巨大的错误,这并不让我在我的手机上运行的示例项目。

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:

1 摇篮完成非零退出值1

2 什么是忽略InnerClasses属性警告编译时输出?

我不知道他们适用于我的情况。我甚至能的执行的项目。我已经更新了我的IDE SDK工具22.0.1及修改 buildToolsVersion 标记在我的 build.gradle 文件,但无济于事。是否有人可以指导我如何处理这个问题?所有帮助将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 意味着你得到两次包括任何。罐

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 媒体链接有 appcompat-V7:22 + ..

Maybe :xyzSDK allready has appcompat-v7:22+..

我给你那里通过@CommonsWare很好的答案中做出摇篮报告,看看有什么问题。

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

和顺便说一句,我认为,我已经读了你询问你是否可以使用 JAVA 8 为Android,而不是 JAVA 7 ,如果我没有错....是的,你可以使用 JDK 8 ,但前提是你还可以使用摇篮,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..

这篇关于机器人工作室的错误 - 意外的顶级例外:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆