How to debug an application in Android Studio?

Asked 12-Jan-2018
Viewed 947 times

1 Answer


0

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.
How to debug an application in 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)

Comment
Thanks for the reply! - Anonymous User19-Jan-2018