找不到Android应用程序类

时间:2012-04-04 08:51:22

标签: android ant android-emulator intellij-idea

在我的应用程序中,我使用RoboGuice,RoboGuice的配置需要添加一个Application-class,并使用'android:name'属性在application-tag的AndroidManifest.xml文件中指定它。

这就是我在清单中的applicaiton-tag的样子:

<application android:label="Worktime" android:icon="@drawable/logo" android:name=".guice.Application">

当我在IDE(IntelliJ)中编译并将其部署到我的设备时,这总是有效的。 但是,当我想使用Ant运行我的测试时(并且只通过Ant,这也可以在IDE中运行)我在控制台上出现此错误:

[exec] android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests:INSTRUMENTATION_RESULT: shortMsg=Unable to instantiate application eu.vranckaert.worktime.guice.Application: java.lang.ClassNotFoundException: eu.vranckaert.worktime.guice.Application in loader dalvik.system.PathClassLoader@44e88928 [exec] INSTRUMENTATION_RESULT: longMsg=java.lang.RuntimeException: Unable to instantiate application eu.vranckaert.worktime.guice.Application: java.lang.ClassNotFoundException: eu.vranckaert.worktime.guice.Application in loader dalvik.system.PathClassLoader@44e88928

之前这已经奏效,但自从我将“Android SDK工具”升级到第17版并将“Android SDK平台工具”升级到第11版后,开始失败。

任何遇到此问题的人还是谁知道如何修复它?

2 个答案:

答案 0 :(得分:0)

I think that the error saying

java.lang.ClassNotFoundException: 

is occur only when you have create new class Activity and not declare(register) that in manifest file

please check if you have any new activity and not declare(register) that activity in manifest file 

Thanks. 

答案 1 :(得分:0)

我们可能遇到过相同的error - 在我的例子中,解决方案是将Ant目标分成两个调用(即“ant myParameters myTarget1 myTarget2”和“ant myParameters debug delivery”)。希望这对你有用,无论如何 - 谷歌需要为他们的无证/错误变化添加更好的支持(并且stackoverflow不是不是由于愚蠢而产生的问题的最佳位置,因为复杂问题的生命周期不会太长这里)。