You are on page 1of 10

Debugging

Layout
Layout
Main Activity
HOMEWORK
Using logcat
• Log.d(<tag>, <msg>)
private static final String MAIN_ACTIVITY = “MainActivity”;
Log.d(MAIN_ACTIVITY, “onCreate”);
• Clear log before launch
• Run > Edit Configurations…
• Logcat
• Check Clear log before launch > OK
• Filter messages in the log
• Log level: Debug
Using Toast
• Toast.makeText(this, "Activity created", Toast.LENGTH_LONG).show();
Breakpoint
• Add a break point: Click on the left
• Run the debugging program
• Make sure that the emulator is at the Home screen
• Click the Debug ‘app’ icon
• Add watch variables
• Mark the variable you want to watch
• Right-click > Add to Watches
• Stepping toolbar
• Make the break point to be conditional
• Right-click on the break point > [i == 8] > Done
• Click the Resume icon
• Finish the debugging: Click the Stop button
• Clear the break point: Click the icon again

You might also like