Android Studio: Debug Project
This post is for beginners, to give basic understanding to debug project in Android Studio.
To debug Project, you have to place breakpoints at the code line, of a method or class, So the debugger will stop at that break point while debugging.
To place a break point just click on work space left side border you can see red dot. To remove breakpoint just click on red dot again.
To debug a project from starting screen of your app, You have to click on the Debug menu button, or Press Shift+ F9
*generally, while debugging app slows down.
So, You can use another debug option to debug at a Specific Screen.
At times you may want to debug code in a Specific screen at a particular line for eg. on a Save button click event method.
So, Place a breakpoint at that particular onClick(View v)
method.
And just run the app by clicking Run menu button
After running app on device or emulator, navigate to the Specific screen and just before clicking on Save button(button event where you want to debug code) in screen. Click on Attach debugger to Android Process menu button in Android Studio work space.
You’ll see a dialog to select a process, here select your process (and wait for a moment for debugger to attach to process) and now click on the Save button in that Specific screen. You can see Debug console at the bottom and debugger waits at break point at a specific line to enable you start debugging.
Here I just like to explain few useful debug console button functionalities
Press F8 or click on the below debug console button icon, to move debugger to next line.. and so on…
Press F7 or click on the below debug console button icon, to move debugger to in to a inner class method.(This is very rarely used). Use it whenever a method call is escaping from debugging.
Press F9 or click on the below debug console button icon, to execute code up to next break point..
Press Ctrl+F2 or click on the below debug console button icon, to stop debugger execution, when you click on this button, debugger stops execution and app runs normally.
these buttons are mainly used for debugging. If you understand these button functions first then You can see and understand other button functions easily.
You can see all variables data and instances data of Specific screen in Variable section…
Hope it makes sense and helps somebody.
cheers 🙂
You may also interested in
- No Update and Restart button to download latest version in Android Studio,
- Integrate BitBucket Plug in Android Studio,
- Create new Class extends a Superclass- Android Studio
- Unmappable character for encoding UTF-8 in Android Studio
- Useful Keymap Shortcuts and Settings Android Studio Startup guide
- Android Studio ADB wipes out logcat quickly when app crashes
One thought on “How to debug project, Android Studio”
Reblogged this on Dinesh Ram Kali..