-4
12-20 13:52:15.071: D/AndroidRuntime(278): Shutting down VM
12-20 13:52:15.081: W/dalvikvm(278): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-20 13:52:15.100: E/AndroidRuntime(278): FATAL EXCEPTION: main
12-20 13:52:15.100: E/AndroidRuntime(278): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebonybutler.cexample3/com.ebonybutler.cexample3.Main}: java.lang.NullPointerException
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.os.Looper.loop(Looper.java:123)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 13:52:15.100: E/AndroidRuntime(278):  at java.lang.reflect.Method.invokeNative(Native Method)
12-20 13:52:15.100: E/AndroidRuntime(278):  at java.lang.reflect.Method.invoke(Method.java:521)
12-20 13:52:15.100: E/AndroidRuntime(278):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 13:52:15.100: E/AndroidRuntime(278):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 13:52:15.100: E/AndroidRuntime(278):  at dalvik.system.NativeStart.main(Native Method)
12-20 13:52:15.100: E/AndroidRuntime(278): Caused by: java.lang.NullPointerException
12-20 13:52:15.100: E/AndroidRuntime(278):  at com.ebonybutler.cexample3.Main.onCreate(Main.java:21)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-20 13:52:15.100: E/AndroidRuntime(278):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-20 13:52:15.100: E/AndroidRuntime(278):  ... 11 moreenter code here
Flo
  • 27,355
  • 15
  • 87
  • 125
user1026229
  • 11
  • 1
  • 8

3 Answers3

1

These lines here:

12-20 13:52:15.100: E/AndroidRuntime(278): Caused by: java.lang.NullPointerException
12-20 13:52:15.100: E/AndroidRuntime(278):  at com.ebonybutler.cexample3.Main.onCreate(Main.java:21)

suggest that something being used on line 21 of cexample3.Main.onCreate is null, so the code can't continue to execute.

I suggest placing a breakpoint above that line, then debugging to see what object is supposed to be available there. Then you can drill down to finding why that object isn't available (for example, maybe it wasn't initialized properly, or perhaps it has gone out of scope by that point).

Added: Based on your comment above

Hi guys, this is what is on line 21:b.setOnClickListener(new OnClickListener() – user1026229

it looks like the object represented with the variable 'b' (b.setOnClickListener...) probably is null. If so, next step is to find out why...

leanne
  • 7,940
  • 48
  • 77
0

Check that all the ids(for buttons ) you given correctly or not

Reddy
  • 140
  • 1
  • 5
  • I checked the Main.java to check the button there. There is only one button and based on the id number it corresponds with the xml file. Is there error only on the Main.java file? – user1026229 Dec 20 '11 at 19:10
0

These are the possible conditions for your problem. 1. you didnt done proper type casting for widgets. 2. some value is null in oncreate method.

so try to check one again main.java oncreate method and check you given all userpermissions properly

Reddy
  • 140
  • 1
  • 5