无法在Android模拟器上加载活动?

时间:2012-04-02 13:25:51

标签: android cordova

最近,我使用最新工具更新了Android SDK(Rev.17)。我正在使用Pahonegap 1.3.0

当我加载页面时,我没有在模拟器上获得任何内容并得到以下错误

> 04-02 18:49:31.312: W/dalvikvm(1689): Unable to resolve superclass of
> Lcom/src/test1/Test1Activity; (4) 04-02 18:49:31.362:
> W/dalvikvm(1689): Link of class 'Lcom/src/test1/Test1Activity;' failed
> 04-02 18:49:31.362: D/AndroidRuntime(1689): Shutting down VM 04-02
> 18:49:31.402: W/dalvikvm(1689): threadid=1: thread exiting with
> uncaught exception (group=0x409c01f8) 04-02 18:49:31.522:
> E/AndroidRuntime(1689): FATAL EXCEPTION: main 04-02 18:49:31.522:
> E/AndroidRuntime(1689): java.lang.RuntimeException: Unable to
> instantiate activity
> ComponentInfo{com.src.test1/com.src.test1.Test1Activity}:
> java.lang.ClassNotFoundException: com.src.test1.Test1Activity 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   at
> android.app.ActivityThread.access$600(ActivityThread.java:123) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   at
> android.os.Handler.dispatchMessage(Handler.java:99) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> android.os.Looper.loop(Looper.java:137) 04-02 18:49:31.522:
> E/AndroidRuntime(1689):   at
> android.app.ActivityThread.main(ActivityThread.java:4424) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> java.lang.reflect.Method.invokeNative(Native Method) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> java.lang.reflect.Method.invoke(Method.java:511) 04-02 18:49:31.522:
> E/AndroidRuntime(1689):   at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> dalvik.system.NativeStart.main(Native Method) 04-02 18:49:31.522:
> E/AndroidRuntime(1689): Caused by: java.lang.ClassNotFoundException:
> com.src.test1.Test1Activity 04-02 18:49:31.522:
> E/AndroidRuntime(1689):   at
> dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   at
> java.lang.ClassLoader.loadClass(ClassLoader.java:501) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> java.lang.ClassLoader.loadClass(ClassLoader.java:461) 04-02
> 18:49:31.522: E/AndroidRuntime(1689):     at
> android.app.Instrumentation.newActivity(Instrumentation.java:1023)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
> 04-02 18:49:31.522: E/AndroidRuntime(1689):   ... 11 more

2 个答案:

答案 0 :(得分:1)

您收到的课程未找到例外:

 java.lang.ClassNotFoundException: com.src.test1.Test1Activity

它不是你的apk中的捆绑包,也不是模糊的,或者不在你的清单中。

答案 1 :(得分:0)

我遇到了同样的问题。我的问题是源文件夹中的文件和类的名称与清单中的包名称不匹配。

我通过添加一个名称正确的新类来解决这个问题。

1:找出你的包:com.apps.sampleApp 请注意最终类的名称,在本例中为sampleApp

2:在源代码中确保src / com.apps.sampleApp中有三个是sampleApp.java

如果是的话

确保公共类是sampleApp

如果没有

此处还有另一个文件扩展了DroidGap。将其复制到sampleApp.java并将公共类名称更改为sampleApp

希望能帮助别人,它为我解决了这个问题。