2

How can I debug an Android app to find out which line is not correct?

Noted that I'm using Android Studio. Also I've done every things exactly the same as what my master did. It works for him as well but it doesn't for me. I mean it closes the app and throws "has stopped" error. Ok well, what's wrong?

Shafizadeh
  • 9,960
  • 12
  • 52
  • 89
MostafaUTD
  • 29
  • 6
  • Is your logcat showing any exceptions? – FishStix Jul 18 '16 at 23:31
  • @FishStix Just after that I click on a Button. It show me several red lines. before that , nothing. I cant find which line has problem . – MostafaUTD Jul 18 '16 at 23:35
  • Put a break point on the click listener attached to that button and run the app in AndroidStudio in debug mode. Moving forward, please include more information (e.g. the click listener's code, logcat print statements, exceptions, etc...) – FishStix Jul 18 '16 at 23:37
  • @FishStix I have problems whit break point. How can I put a break point and run in debugging mode ? – MostafaUTD Jul 18 '16 at 23:44

1 Answers1

1

You can put breakpoints via Run -> View Breakpoints.

The Breakpoints dialog appears. In the left pane, scroll to the bottom. Select Any exception under Java Exception Breakpoints With Any exception selected, on the right pane, configure as follows:

Suspend: checked
All: selected
Condition: !(this instanceof java.lang.ClassNotFoundException)
Notifications: both Caught exception and Uncaught exception selected

You can refer this for better understanding.

Community
  • 1
  • 1
Vamsi Abbineni
  • 479
  • 3
  • 7
  • 23