Question

I am beginner for android. Trying to make basic applications. When I tried to run the program after adding an adapter and gridview in my code, the application couldnt be started. These are the lines from the DDMS for failing it. Can anybody please suggest me how do i locate the error contain line from it ? or I cannot ?

02-19 16:53:12.481: D/ActivityThread(1721): setTargetHeapConcurrentStart:2097152

02-19 16:53:12.591: W/dalvikvm(1721): threadid=1: thread exiting with uncaught exception     (group=0x410eb438)

02-19 16:53:12.591: E/AndroidRuntime(1721): FATAL EXCEPTION: main

02-19 16:53:12.591: E/AndroidRuntime(1721): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.zilo/com.example.zilo.MainActivity}: java.lang.NullPointerException

02-19 16:53:12.591: E/AndroidRuntime(1721): at    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2087)

02-19 16:53:12.591: E/AndroidRuntime(1721): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2112)

I am not seeking help to find the error, Please help me to figure out, how to locate the error from DDMS log.

Was it helpful?

Solution

Here are the steps :

1- Go to the first 2 lines of the exception , in your case Fetal Exception, Main and java.lang.RuntimeException so this is the main exception. Sometimes you will find it like Security Exception, NullPOinterException and so on

2- Proceed with all following lines until you find the Caused by lines which mostly will be followed by the line number of the code that causes the problem

3- If you couldn't find the cause by and generally you look at the exception trace line by line until you find some indicator or component name of your code that might cause this problem.

Looking to the second line : Unable to start activity ComponentInfo{com.example.zilo/com.example.zilo.MainActivity}: java.lang.NullPointerException

So here is another clue , NullPointerException that prevents the app from being loaded. probably a problem in onCreate() method or something that prevented MainActivity from being loaded.

I believe this is not the full stack trace, in the following lines of the stack trace you will find the cause. You may post the full exception so that we may assist further.

Hope this helps you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top