Reputation:
Method or Hint for finding error from LogCat. How to find and solve error from Logcat?
Upvotes: 1
Views: 22008
Reputation: 9005
In Android Studio You will See Logcat in Bottom switch to error in that and you have to read all red messages . these are errors
Upvotes: 1
Reputation: 871
In LogCat you will find among all those run time errors there is a tag "Caused by" under text attribute.you will click the next line of that error and that will point you to the code where that error is occurring.
Upvotes: 3
Reputation: 6141
I try to explain on a very basic example of logcat output taken from different post :
12-13 12:41:57.052: W/System.err(542): org.json.JSONException: No value for TAG_CONTACTS
12-13 12:41:57.052: W/System.err(542): at org.json.JSONObject.get(JSONObject.java:354)
12-13 12:41:57.052: W/System.err(542): at org.json.JSONObject.getJSONArray(JSONObject.java:544)
12-13 12:41:57.052: W/System.err(542): at com.androidhive.jsonparsing.AndroidJSONParsingActivity.onCreate(AndroidJSONParsingActivity.java:56)
12-13 12:41:57.063: W/System.err(542): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-13 12:41:57.063: W/System.err(542): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-13 12:41:57.063: W/System.err(542): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-13 12:41:57.063: W/System.err(542): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-13 12:41:57.063: W/System.err(542): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-13 12:41:57.063: W/System.err(542): at android.os.Handler.dispatchMessage(Handler.java:99)
12-13 12:41:57.072: W/System.err(542): at android.os.Looper.loop(Looper.java:123)
12-13 12:41:57.072: W/System.err(542): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-13 12:41:57.072: W/System.err(542): at java.lang.reflect.Method.invokeNative(Native Method)
12-13 12:41:57.072: W/System.err(542): at java.lang.reflect.Method.invoke(Method.java:507)
12-13 12:41:57.072: W/System.err(542): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
As you can see from first line exception is "JSONException" which heppened because of "No value for TAG_CONTACTS". From line number 4 you can see, that it happened in "AndroidJSONParsingActivity" on line 56. Now when you know what is the exception and where it happens, you should be able to solve it !
Upvotes: 5