2

我已经使用 eclipse 创建了一个 android 应用程序,但应用程序没有在 AVD 上运行它说“不幸的是已经停止工作”

日志猫消息如下 -

07-29 04:59:50.789: W/dalvikvm(784): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
07-29 04:59:50.808: E/AndroidRuntime(784): FATAL EXCEPTION: main
07-29 04:59:50.808: E/AndroidRuntime(784): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.androidlove/com.example.androidlove.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.androidlove.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.androidlove-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.androidlove-1, /system/lib]]
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.os.Looper.loop(Looper.java:137)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.ActivityThread.main(ActivityThread.java:5103)
07-29 04:59:50.808: E/AndroidRuntime(784):  at java.lang.reflect.Method.invokeNative(Native Method)
07-29 04:59:50.808: E/AndroidRuntime(784):  at java.lang.reflect.Method.invoke(Method.java:525)
07-29 04:59:50.808: E/AndroidRuntime(784):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-29 04:59:50.808: E/AndroidRuntime(784):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-29 04:59:50.808: E/AndroidRuntime(784):  at dalvik.system.NativeStart.main(Native Method)
07-29 04:59:50.808: E/AndroidRuntime(784): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.androidlove.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.androidlove-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.androidlove-1, /system/lib]]
07-29 04:59:50.808: E/AndroidRuntime(784):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
07-29 04:59:50.808: E/AndroidRuntime(784):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-29 04:59:50.808: E/AndroidRuntime(784):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
07-29 04:59:50.808: E/AndroidRuntime(784):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
07-29 04:59:50.808: E/AndroidRuntime(784):  ... 11 more
07-29 04:59:58.399: I/Process(784): Sending signal. PID: 784 SIG: 9

请帮助我,我厌倦了解决这个错误.....

4

3 回答 3

1

如果包是:com.example.androidlove-1,则根据您的包名称在清单中添加 mainActivity

   <activity
        android:name="com.example.androidlove-1.MainActivity" >
    </activity>
于 2013-07-29T09:12:11.453 回答
1

我遇到了同样的问题,我发现示例代码放在“JAVA”文件夹而不是“src”文件夹中。把代码移到src后,问题就解决了。

我希望这行得通。

于 2014-03-14T01:21:51.653 回答
0

您没有在 manifest.xml 中声明 MainActivity 类。

    <activity
        android:name=".MainActivity" >
    </activity>
于 2013-07-29T09:07:41.473 回答