Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unfortunatly, Sudoku has stopped

 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new in android development.. and my app showing "Unfortunatly, Sudoku has stopped" please help..
LOGCAT

04-05 10:31:42.061: E/AndroidRuntime(848): FATAL EXCEPTION: main

04-05 10:31:42.061: E/AndroidRuntime(848): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sudoku/com.example.sudoku.Sudoku}: java.lang.NullPointerException

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.ActivityThread.access$600(ActivityThread.java:141)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.os.Handler.dispatchMessage(Handler.java:99)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.os.Looper.loop(Looper.java:137)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.ActivityThread.main(ActivityThread.java:5039)

04-05 10:31:42.061: E/AndroidRuntime(848): at java.lang.reflect.Method.invokeNative(Native Method)

04-05 10:31:42.061: E/AndroidRuntime(848): at java.lang.reflect.Method.invoke(Method.java:511)

04-05 10:31:42.061: E/AndroidRuntime(848): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

04-05 10:31:42.061: E/AndroidRuntime(848): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

04-05 10:31:42.061: E/AndroidRuntime(848): at dalvik.system.NativeStart.main(Native Method)

04-05 10:31:42.061: E/AndroidRuntime(848): Caused by: java.lang.NullPointerException

04-05 10:31:42.061: E/AndroidRuntime(848): at com.example.sudoku.Sudoku.onCreate(Sudoku.java:24)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.Activity.performCreate(Activity.java:5104)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

04-05 10:31:42.061: E/AndroidRuntime(848): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

04-05 10:31:42.061: E/AndroidRuntime(848): ... 11 more

04-05 10:31:46.191: I/Process(848): Sending signal. PID: 848 SIG: 9
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the important part: Caused by: java.lang.NullPointerException at com.example.sudoku.Sudoku.onCreate(Sudoku.java:24)

You need to find out which object is null in that line of code, and deal with that.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivam singhal wrote:04-05 10:31:42.061: E/AndroidRuntime(848): FATAL EXCEPTION: main
04-05 10:31:42.061: E/AndroidRuntime(848): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sudoku/com.example.sudoku.Sudoku}: java.lang.NullPointerException

You have a Null Pointer Exception
...
04-05 10:31:42.061: E/AndroidRuntime(848): Caused by: java.lang.NullPointerException
04-05 10:31:42.061: E/AndroidRuntime(848): at com.example.sudoku.Sudoku.onCreate(Sudoku.java:24)

On Sudoku line 24, in the onCreate() method. Some object you are trying to use there is null, and needs to be not null.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Steve..
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


what else i am missin in line 24?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivam singhal wrote:what else i am missin in line 24?

Apparently an object ;)

Check the layout and make sure that the view you are trying to use exists and has the id set to continue_label. You might have different layouts in different resource folders based on screen size, language, or rotation. So double check all locations.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry unable to find my error..

here is my strings.xml




and my R.java file
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivam singhal wrote:here is my strings.xml
...
and my R.java file

Thats all well and good, but, as I said, the place you should be looking is your layout.
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am Working on eclipse(ADT)
And I think the naming mistake couldn't happen in eclipse as on every moment when i am writing the code IDE always looking up for the same name in the defined file..

Steve I am New to Android Development and there are lots of files linked with each other may be that's why I am unable to findout my error..

Here is the layout file, that I am using
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now., I Think have found my mistake..
Thanks steve..
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell me one thing ..
how do you know that its a layout problem??
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shivam singhal wrote:please tell me one thing ..
how do you know that its a layout problem??


I didn't know, but I had a strong inkling it was layout related.

The line you pointed to had two references in it, this and ContinueButton. The value pointed to by this can't be null. so the other reference had to be null. The ContinueButton was retrieved by findViewById(), which, as you can see in the API returns null when the view can't be found. The id you pass in must exist, or at least existed in the past, because it was present in R.id. So if the View exists and it isn't found then the view must not be present in the current layout. That means your layout might not be what you think it is. There is plenty of room for this type of mistake so it seemed a likely cause of the problem (a problem I have stepped into a fair amount of times).
 
shivam singhal
Ranch Hand
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks steve..

Done ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic