0

I wonder if any one can help me, I'm writing an android program and whenever I run the emulator, these errors show up:

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

I'm trying to write a grid view code, I would really appreciate it if anyone could help, thanks a lot :)

mango
  • 5,577
  • 4
  • 29
  • 41
lolo
  • 1
  • 2
  • ClassNotFoundException is the meaningful part. Read those lines. Also, those aren't multiple errors. It's the stack trace for one error. – keyser Mar 24 '13 at 15:16

2 Answers2

1

Make sure you declared your activity com.example.gridviewexample.MainActivity in your AndroidManifest.xml.

Also, make sure that your MainActivity has the correct package name set in the top of the file (e.g package com.example.gridviewexample).

Halim Qarroum
  • 13,985
  • 4
  • 46
  • 71
  • Thanks a lot, I really appreciate your help :) But I also have another question and would really appreciate your help again, if I would like to make 2 boards in the same activity that's 10*10 each, and I want to fill the cells with the same image, such that there are 200 images of the same one, how could I do that? do I make an array that has these 200 images in the imageAdapter class? – lolo Mar 25 '13 at 17:54
  • Well I mean that I want to make 2 boards, each board is 10*10 (10 rows by 10 columns), and I want to fill the 2 boards with a single image (all the cells have the same image), how would I do that using grid view? – lolo Mar 25 '13 at 18:52
  • As @seb said, create a new thread for your question. Someone might give you a better answer which will be properly referenced. – Halim Qarroum Mar 25 '13 at 19:57
0

The system cannot find the MainActivity.class in your com.example.gridviewexample package.

Take a look to see if you have such a class in there.

A Project -> Clean could also help(provided you're using Eclipse).

sebster
  • 1,322
  • 2
  • 18
  • 29
  • No problem. Good luck with your project. – sebster Mar 25 '13 at 17:59
  • I'm kind of new to the site, and I want to add your reputation, how can I do that? haha – lolo Mar 25 '13 at 18:54
  • On the left of the post you have a number with 2 arrows and a check mark. Selecting the check mark means you have accepted the answer as the solution. You can also vote-up or down the answer by using the arrows. – sebster Mar 25 '13 at 19:22
  • 1
    Also, a piece of advice. I see that you are asking additional questions in comments. Try to create a new question instead of asking it in the chat. A lot more useful and it can contribute to the community as well. – sebster Mar 25 '13 at 19:24