我想知道是否有人可以帮助我,我正在编写一个Android程序,每当我运行模拟器时,这些错误都会显示出来:
03-24 15:06:17.464: E/AndroidRuntime(792): FATAL EXCEPTION: main
03-24 15:06:17.464: E/AndroidRuntime(792): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.gridviewexample/com.example.gridviewexample.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.gridviewexample.MainActivity" on path: /data/app/com.example.gridviewexample-2.apk
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.os.Looper.loop(Looper.java:137)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-24 15:06:17.464: E/AndroidRuntime(792): at java.lang.reflect.Method.invokeNative(Native Method)
03-24 15:06:17.464: E/AndroidRuntime(792): at java.lang.reflect.Method.invoke(Method.java:511)
03-24 15:06:17.464: E/AndroidRuntime(792): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-24 15:06:17.464: E/AndroidRuntime(792): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-24 15:06:17.464: E/AndroidRuntime(792): at dalvik.system.NativeStart.main(Native Method)
03-24 15:06:17.464: E/AndroidRuntime(792): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.gridviewexample.MainActivity" on path: /data/app/com.example.gridviewexample-2.apk
03-24 15:06:17.464: E/AndroidRuntime(792): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
03-24 15:06:17.464: E/AndroidRuntime(792): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-24 15:06:17.464: E/AndroidRuntime(792): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
03-24 15:06:17.464: E/AndroidRuntime(792): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
03-24 15:06:17.464: E/AndroidRuntime(792): ... 11 more
我正在尝试编写一个网格视图代码,如果有人能提供帮助我真的很感激,非常感谢:)
答案 0 :(得分:1)
确保您在AndroidManifest.xml中宣布了自己的活动com.example.gridviewexample.MainActivity
。
另外,请确保您的MainActivity
在文件顶部设置了正确的包名称(例如 package com.example.gridviewexample
)。
答案 1 :(得分:0)
系统无法在com.example.gridviewexample包中找到 MainActivity.class 。
看看你是否有这样的课程。
项目 - > Clean也可以提供帮助(假设您使用的是Eclipse)。