如何解决 Android Studio 中的 UNEXPECTED TOP-LEVEL EXCEPTION [英] How to resolve UNEXPECTED TOP-LEVEL EXCEPTION in Android Studio

查看:41
本文介绍了如何解决 Android Studio 中的 UNEXPECTED TOP-LEVEL EXCEPTION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个共享同一个 aidl 文件的项目.

I have two projects that share the same aidl file.

在第一个项目中,构建在 Eclipse 和 Android Studio 中运行完成.

In the first project, the build runs to completion in Eclipse and Android Studio.

在第二个项目中,构建在 Eclipse 中运行完成,但在 Android Studio 中我看到:

In the second project, the build runs to completion in Eclipse, BUT in Android Studio I see:

Error:[Tracker-PRO-Key] UNEXPECTED TOP-LEVEL EXCEPTION:
Error:[Tracker-PRO-Key] com.android.dx.util.ExceptionWithContext
Error:[Tracker-PRO-Key] at com.android.dx.util.ExceptionWithContext.withContext(ExceptionWithContext.java:46)
Error:[Tracker-PRO-Key] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:344)
Error:[Tracker-PRO-Key] at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:134)
Error:[Tracker-PRO-Key] at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:87)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main.processClass(Main.java:487)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main.access$400(Main.java:67)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
Error:[Tracker-PRO-Key] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:135)
Error:[Tracker-PRO-Key] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main.processOne(Main.java:422)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
Error:[Tracker-PRO-Key] at com.android.dx.command.dexer.Main.run(Main.java:209)
Error:[Tracker-PRO-Key] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:[Tracker-PRO-Key] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error:[Tracker-PRO-Key] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:[Tracker-PRO-Key] at java.lang.reflect.Method.invoke(Method.java:606)
Error:[Tracker-PRO-Key] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
Error:[Tracker-PRO-Key] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:261)
Error:[Tracker-PRO-Key] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
Error:[Tracker-PRO-Key] Caused by: java.lang.NullPointerException
Error:[Tracker-PRO-Key] at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:87)
Error:[Tracker-PRO-Key] at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:75)
Error:[Tracker-PRO-Key] at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:247)
Error:[Tracker-PRO-Key] ... 22 more
Error:[Tracker-PRO-Key] ...while processing <init> (Lcom/DynaZu/Tracker/Prokey/MainActivity;)V
Error:[Tracker-PRO-Key] ...while processing /home/joel/workspace/Tracker-PRO-Key/out/production/Tracker-PRO-Key/com/DynaZu/Tracker/Prokey/MainActivity$1.class
Error:[Tracker-PRO-Key] 1 error; aborting

aidl 文件极其简单:

The aidl file is extremely simple:

package com.DynaZu.Tracker.Prokey;
interface IProKEYComm {
    long getLicenseInfo();
}

如何确定问题????这是什么原因造成的?我正在使用 com.google.android.vending.licensing.这可能有关系吗?
我见过一个库被包含两次(不同版本)的问题,但这似乎不是这里的问题.任何想法将不胜感激!

HOW to determine the problem???? What causes this? I am using com.google.android.vending.licensing. Could this be related?
I have seen problems where a library is included twice (with different versions), but this doesn't seem to be the issue here. Any ideas would be greatly appreciated!

推荐答案

经过数月的努力,我终于找到了适合我的解决方案.这可能不是你的情况.确保您使用的所有类(在您的情况下,可能是接口本身,因为我没有看到任何其他类)是私有的.Gradle 无法处理它,也无法在类中找到方法.只需将其更改为 public(在嵌套类的情况下,您只需删除标志以使其成为默认值),您应该很高兴.

After months of fighting this exact problem, I have finally found a solution that works for me. It might not be your case. Make sure, that none of the classes you are using (in your case, it is probably the interface itself, since I don't see any others) is private. The Gradle is not able to handle it and cannot find the methods within the class. Just change it to public (in case of nested classes, you only need to remove the flag to make it default), and you should be good to go.

这篇关于如何解决 Android Studio 中的 UNEXPECTED TOP-LEVEL EXCEPTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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