How to debug an application in Android Studio?

1 votes
314 views
Anonymous User asked 12-Jan-2018 in Technology by Anonymous User

How to debug an application in Android Studio?

1 Answer

0 votes
Prateek sharma answered 17-Jan-2018 by Prateek sharma
Debugging can be done by either creating log statements which will execute at the runtime or set the breakpoints.
Debugging by setting breakpoints.
In order to start with this debugging, you need to enable the debugging. To do this follow the steps –
1. Install LLDB from the SDK Manager.
2. Enable debugging on your device.
3. Run a debuggable build variant:  You need to simply do this in your build.gradle file
android {

    buildTypes {
        customDebugType {
            debuggable true
        }
    }
}
To start debugging follow the steps –
1. Set some breakpoints in your code.
2. Click the debug button from your android studio toolbar
3. This will open a window with the connected devices, simply select any one and click Ok.
How to debug an application in Android Studio?
4. This action will open a debug window showing current thread and object tree for the variable.
5. If you want to move to the next line while debugging you need to click on f7.
Debugging by log statements.
To generate the log you need to look at the log monitor which is situated at the bottom of the android studio.

This will show all the log details to you.
you can insert the various log comments from your code, for example, to insert verbose you need to write-
Log.v("TAG", "MESSAGE");
there are various types of Logging statements you can write for various purposes -
1. Log.e(String, String) (error)
2. Log.w(String, String) (warning)
3. Log.i(String, String) (information)
4. Log.d(String, String) (debug)
5. Log.v(String, String) (verbose)
TarunGautam commented 19-Jan-2018 by TarunGautam
Thanks for the reply!
       1