1

Method or Hint for finding error from LogCat. How to find and solve error from Logcat?

Abhi
  • 8,935
  • 7
  • 37
  • 60
  • Please post the logcat, then we can talk you through it. – Simon Dec 13 '12 at 10:15
  • Error will be shown in red color. In eclipse click on DDMS perspective. In DDMS perspective, left panel, select emulator (or the device listed). And you will get the logcat. – kumar Dec 13 '12 at 10:15
  • What do you mean by "find"? The error usually gets printed in LogCat as it does in a normal java program – HashtagMarkus Dec 13 '12 at 10:15

4 Answers4

5

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 !

slezadav
  • 6,104
  • 7
  • 40
  • 61
3

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.

Sifat Ifty
  • 851
  • 6
  • 4
1

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

Sam Massy
  • 5
  • 2
Abhi
  • 8,935
  • 7
  • 37
  • 60
1

I like this approach:

adb logcat -s System.err
DenisKolodin
  • 13,501
  • 3
  • 62
  • 65