SlideShare a Scribd company logo
1 of 18
ANDROID
DEVELOPMENT
SESSION 5 – DEBUGGING WITH ANDROID STUDIO
AHMED EZZ EL - DIN
facebook.com/ahmed.e.hassan
1
SESSION CONTENT
• Introduction
• Run your App in Debug Mode.
• Use system Log
• Work with Breakpoints
• Track object Allocation
• Capture Screenshots and Videos
facebook.com/ahmed.e.hassan
2
INTRODUCTION
facebook.com/ahmed.e.hassan
3
Android Studio enables you to debug apps running on the emulator or on an
Android device. With Android Studio, you can:
• Select a device to debug your app on.
• View the system log.
• Set breakpoints in your code.
• Examine variables and evaluate expressions at run time.
• Run the debugging tools from the Android SDK.
• Capture screenshots and videos of your app.
RUN YOUR APP IN
DEBUG MODE
facebook.com/ahmed.e.hassan
4
To run your app in debug mode, you build an APK signed with a debug key and install it on
a physical Android device or on the Android emulator
To debug your app in Android Studio:
1. Open your project in Android Studio.
2. Click Debug in the toolbar.
3. On the Choose Device window, select a hardware device from the list or choose a
virtual device.
4. Click OK. Your app starts on the selected device.
facebook.com/ahmed.e.hassan
5
RUN YOUR APP IN
DEBUG MODE
Android Studio opens the Debug tool window when you debug your app.
To open the Debug window manually, click Debug
This window shows threads and variables in the Debugger tab, the device status
in the Console tab, and the system log in the Logcat tab.
facebook.com/ahmed.e.hassan
6
RUN YOUR APP IN
DEBUG MODE
Attach the debugger to a running process
You don't always have to restart your app to debug it. To debug an app that you're
already running:
1. Click Attach debugger to Android process .
2. In the Choose Process window, select the device and app you want to attach the
debugger to.
3. To open the Debug tool window, click Debug
USE THE SYSTEM LOG
facebook.com/ahmed.e.hassan
7
The system log shows system messages while you debug your app.
These messages include information from apps running on the device.
If you want to use the system log to debug your app, make sure your code writes log
messages and prints the stack trace for exceptions while your app is in the
development phase.
facebook.com/ahmed.e.hassan
8
USE THE SYSTEM LOG
During development, your code can also catch exceptions and write the stack trace to the
system log:
facebook.com/ahmed.e.hassan
9
USE THE SYSTEM LOG
View the system log
To view the system log on the Android DDMS tool window:
1. Start your app .
2. Click Android to open the Android DDMS tool window.
3. If the system log is empty in the Logcat view, click Restart .
facebook.com/ahmed.e.hassan
10
USE THE SYSTEM LOG
The system log shows messages from Android services and other Android apps. To
filter the log messages to view only the ones you are interested in, use the tools in the
Android DDMS window:
• To show only log messages for a particular process, select the process in the Devices view and
then click Only Show Logcat from Selected Process . If the Devices view is not available,
click Restore Devices View on the right of the Android DDMS tool window. This button is
only visible when you hide the Devices window.
• To filter log messages by log level, select a level under Log Level on the top of the Android
DDMS window.
• To show only log messages that contain a particular string, enter the string in the search box
and press Enter.
WORK WITH
BREAKPOINTS
facebook.com/ahmed.e.hassan
11
Breakpoints enable you to pause the execution of your app at a particular line of
code, examine variables, evaluate expressions, and continue the execution line
by line.
Use breakpoints to determine the causes of run-time errors that you can't fix
by looking at your code only.
To debug your app using breakpoints:
1. Open the source file in which you want to set a breakpoint.
2. Locate the line where you want to set a breakpoint and click on it.
3. Click on the yellow portion of the side bar to the left of this line
4. Start your app
facebook.com/ahmed.e.hassan
12
WORK WITH
BREAKPOINTS
View and configure breakpoints
To view all the breakpoints and configure breakpoint settings, click View Breakpoints
on the left side of the Debug tool window. The Breakpoints window appears
facebook.com/ahmed.e.hassan
13
WORK WITH
BREAKPOINTS
Debug your app with breakpoints
After you set breakpoints in your code, click Rerun to start the app again.
When a breakpoint is hit, Android Studio pauses the app and highlights the breakpoint in
the source code.
• To examine the object tree for a variable, expand it in the Variables view. If the Variables view is not
visible, click Restore Variables View .
• To evaluate an expression at the current execution point, click Evaluate Expression .
• To advance to the next line in the code (without entering a method), click Step Over .
• To advance to the first line inside a method call, click Step Into .
• To advance to the next line outside the current method, click Step Out .
• To continue running the app normally, click Resume Program
facebook.com/ahmed.e.hassan
14
WORK WITH
BREAKPOINTS
TRACK OBJECT
ALLOCATION
facebook.com/ahmed.e.hassan
15
Android Studio lets you track objects that are being allocated on the Java heap and see
which classes and threads are allocating these objects. This allows you to see the list of
objects allocated during a period of interest. This information is valuable for assessing
memory usage that can affect application performance.
To track memory allocation of objects:
1. Start your app.
2. Click Android to open the Android DDMS tool window.
3. On the Android DDMS tool window, select the Devices | logcat tab.
4. Select your device from the dropdown list.
5. Select your app by its package name from the list of running apps.
6. Click Start Allocation Tracking
7. Interact with your app on the device.
8. Click Stop Allocation Tracking
facebook.com/ahmed.e.hassan
16
TRACK OBJECT
ALLOCATION
Android Studio shows the objects that the system allocated with the following information:
• Allocation order
• Allocated class
• Allocation size
• Thread ID
• Allocation method, class, and line number
• Stack trace at the point of allocation
CAPTURE SCREENSHOTS
AND VIDEOS
facebook.com/ahmed.e.hassan
17
Android Studio enables you to capture a screenshot or a short video of the device
screen while your app is running.
Screenshots and videos are useful as promotional materials for your app, and you can
also attach them to bug reports that you send to your development team.
To take a screenshot of your app:
1. Start your app.
2. Click Android to open the Android DDMS tool window.
3. Click Screen Capture on the left side of the Android DDMS tool window.
4. Optional: To add a device frame around your screenshot, enable the Frame screenshot option.
5. Click Save.
facebook.com/ahmed.e.hassan
18
CAPTURE SCREENSHOTS
AND VIDEOS
To take a video recording of your app:
1. Start your app.
2. Click Android to open the Android DDMS tool window.
3. Click Screen Record on the left side of the Android DDMS tool window.
4. Click Start Recording.
5. Interact with your app.
6. Click Stop Recording.
7. Enter a file name for the recording and click OK.

More Related Content

What's hot

Shared preferences
Shared preferencesShared preferences
Shared preferencesSourabh Sahu
 
android activity
android activityandroid activity
android activityDeepa Rani
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycleSoham Patel
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android FragmentsSergi Martínez
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in androidPrawesh Shrestha
 
Android resources
Android resourcesAndroid resources
Android resourcesma-polimi
 
Java exception handling
Java exception handlingJava exception handling
Java exception handlingBHUVIJAYAVELU
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android StudioSuyash Srijan
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation ComponentŁukasz Ciupa
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 

What's hot (20)

Shared preferences
Shared preferencesShared preferences
Shared preferences
 
android activity
android activityandroid activity
android activity
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
OOP java
OOP javaOOP java
OOP java
 
Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Android resources
Android resourcesAndroid resources
Android resources
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation Component
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
C#.NET
C#.NETC#.NET
C#.NET
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Android Data Storagefinal
Android Data StoragefinalAndroid Data Storagefinal
Android Data Storagefinal
 

Similar to ANDROID DEBUGGING SESSION

Android software development – the first few hours
Android software development – the first few hoursAndroid software development – the first few hours
Android software development – the first few hourssjmarsh
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thRishi Kumar
 
Hospital app project (how to upload app)
Hospital app project (how to upload app)Hospital app project (how to upload app)
Hospital app project (how to upload app)MAHFUZ RAIHAN
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read merubi hartanto
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read mePhp RedStorm
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read meBo Ei
 
How to create android applications
How to create android applicationsHow to create android applications
How to create android applicationsTOPS Technologies
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read meok71
 
How To Run/Test Flutter App On a Real Device?
How To Run/Test Flutter App On a Real Device?How To Run/Test Flutter App On a Real Device?
How To Run/Test Flutter App On a Real Device?Flutter Agency
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appiumPratik Patel
 
5 Easy Steps to Learn Espresso
5 Easy Steps to Learn Espresso5 Easy Steps to Learn Espresso
5 Easy Steps to Learn EspressoRaman Gowda Hullur
 
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdfPERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdfarfa442827
 
Expert Guidance on debugging React Native Apps: Recommended Practices and Han...
Expert Guidance on debugging React Native Apps: Recommended Practices and Han...Expert Guidance on debugging React Native Apps: Recommended Practices and Han...
Expert Guidance on debugging React Native Apps: Recommended Practices and Han...Shelly Megan
 
Dev windows phone_apps_getting_started_guide
Dev windows phone_apps_getting_started_guideDev windows phone_apps_getting_started_guide
Dev windows phone_apps_getting_started_guideTrioBlack Trioblack
 
Bai thuc hanh lap trinh Android so 1
Bai thuc hanh lap trinh Android so 1Bai thuc hanh lap trinh Android so 1
Bai thuc hanh lap trinh Android so 1Frank Pham
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceOleksii Prohonnyi
 

Similar to ANDROID DEBUGGING SESSION (20)

Build Your First Android App
Build Your First Android AppBuild Your First Android App
Build Your First Android App
 
Android software development – the first few hours
Android software development – the first few hoursAndroid software development – the first few hours
Android software development – the first few hours
 
Android app development guide for freshers by ace web academy
Android app development guide for freshers  by ace web academyAndroid app development guide for freshers  by ace web academy
Android app development guide for freshers by ace web academy
 
Homework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12thHomework seriesandroidworkshop JUly 12th
Homework seriesandroidworkshop JUly 12th
 
Hospital app project (how to upload app)
Hospital app project (how to upload app)Hospital app project (how to upload app)
Hospital app project (how to upload app)
 
Appium- part 1
Appium- part 1Appium- part 1
Appium- part 1
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read me
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read me
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read me
 
How to create android applications
How to create android applicationsHow to create android applications
How to create android applications
 
Dreamweaver cs5 read me
Dreamweaver cs5 read meDreamweaver cs5 read me
Dreamweaver cs5 read me
 
How To Run/Test Flutter App On a Real Device?
How To Run/Test Flutter App On a Real Device?How To Run/Test Flutter App On a Real Device?
How To Run/Test Flutter App On a Real Device?
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
5 Easy Steps to Learn Espresso
5 Easy Steps to Learn Espresso5 Easy Steps to Learn Espresso
5 Easy Steps to Learn Espresso
 
How to build your own Android App -Step by Step Guide
How to build your own Android App -Step by Step GuideHow to build your own Android App -Step by Step Guide
How to build your own Android App -Step by Step Guide
 
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdfPERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
PERTEMUAN 3_INTRO TO ANDROID APP DEV.pdf
 
Expert Guidance on debugging React Native Apps: Recommended Practices and Han...
Expert Guidance on debugging React Native Apps: Recommended Practices and Han...Expert Guidance on debugging React Native Apps: Recommended Practices and Han...
Expert Guidance on debugging React Native Apps: Recommended Practices and Han...
 
Dev windows phone_apps_getting_started_guide
Dev windows phone_apps_getting_started_guideDev windows phone_apps_getting_started_guide
Dev windows phone_apps_getting_started_guide
 
Bai thuc hanh lap trinh Android so 1
Bai thuc hanh lap trinh Android so 1Bai thuc hanh lap trinh Android so 1
Bai thuc hanh lap trinh Android so 1
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

ANDROID DEBUGGING SESSION

  • 1. ANDROID DEVELOPMENT SESSION 5 – DEBUGGING WITH ANDROID STUDIO AHMED EZZ EL - DIN facebook.com/ahmed.e.hassan 1
  • 2. SESSION CONTENT • Introduction • Run your App in Debug Mode. • Use system Log • Work with Breakpoints • Track object Allocation • Capture Screenshots and Videos facebook.com/ahmed.e.hassan 2
  • 3. INTRODUCTION facebook.com/ahmed.e.hassan 3 Android Studio enables you to debug apps running on the emulator or on an Android device. With Android Studio, you can: • Select a device to debug your app on. • View the system log. • Set breakpoints in your code. • Examine variables and evaluate expressions at run time. • Run the debugging tools from the Android SDK. • Capture screenshots and videos of your app.
  • 4. RUN YOUR APP IN DEBUG MODE facebook.com/ahmed.e.hassan 4 To run your app in debug mode, you build an APK signed with a debug key and install it on a physical Android device or on the Android emulator To debug your app in Android Studio: 1. Open your project in Android Studio. 2. Click Debug in the toolbar. 3. On the Choose Device window, select a hardware device from the list or choose a virtual device. 4. Click OK. Your app starts on the selected device.
  • 5. facebook.com/ahmed.e.hassan 5 RUN YOUR APP IN DEBUG MODE Android Studio opens the Debug tool window when you debug your app. To open the Debug window manually, click Debug This window shows threads and variables in the Debugger tab, the device status in the Console tab, and the system log in the Logcat tab.
  • 6. facebook.com/ahmed.e.hassan 6 RUN YOUR APP IN DEBUG MODE Attach the debugger to a running process You don't always have to restart your app to debug it. To debug an app that you're already running: 1. Click Attach debugger to Android process . 2. In the Choose Process window, select the device and app you want to attach the debugger to. 3. To open the Debug tool window, click Debug
  • 7. USE THE SYSTEM LOG facebook.com/ahmed.e.hassan 7 The system log shows system messages while you debug your app. These messages include information from apps running on the device. If you want to use the system log to debug your app, make sure your code writes log messages and prints the stack trace for exceptions while your app is in the development phase.
  • 8. facebook.com/ahmed.e.hassan 8 USE THE SYSTEM LOG During development, your code can also catch exceptions and write the stack trace to the system log:
  • 9. facebook.com/ahmed.e.hassan 9 USE THE SYSTEM LOG View the system log To view the system log on the Android DDMS tool window: 1. Start your app . 2. Click Android to open the Android DDMS tool window. 3. If the system log is empty in the Logcat view, click Restart .
  • 10. facebook.com/ahmed.e.hassan 10 USE THE SYSTEM LOG The system log shows messages from Android services and other Android apps. To filter the log messages to view only the ones you are interested in, use the tools in the Android DDMS window: • To show only log messages for a particular process, select the process in the Devices view and then click Only Show Logcat from Selected Process . If the Devices view is not available, click Restore Devices View on the right of the Android DDMS tool window. This button is only visible when you hide the Devices window. • To filter log messages by log level, select a level under Log Level on the top of the Android DDMS window. • To show only log messages that contain a particular string, enter the string in the search box and press Enter.
  • 11. WORK WITH BREAKPOINTS facebook.com/ahmed.e.hassan 11 Breakpoints enable you to pause the execution of your app at a particular line of code, examine variables, evaluate expressions, and continue the execution line by line. Use breakpoints to determine the causes of run-time errors that you can't fix by looking at your code only. To debug your app using breakpoints: 1. Open the source file in which you want to set a breakpoint. 2. Locate the line where you want to set a breakpoint and click on it. 3. Click on the yellow portion of the side bar to the left of this line 4. Start your app
  • 12. facebook.com/ahmed.e.hassan 12 WORK WITH BREAKPOINTS View and configure breakpoints To view all the breakpoints and configure breakpoint settings, click View Breakpoints on the left side of the Debug tool window. The Breakpoints window appears
  • 13. facebook.com/ahmed.e.hassan 13 WORK WITH BREAKPOINTS Debug your app with breakpoints After you set breakpoints in your code, click Rerun to start the app again. When a breakpoint is hit, Android Studio pauses the app and highlights the breakpoint in the source code. • To examine the object tree for a variable, expand it in the Variables view. If the Variables view is not visible, click Restore Variables View . • To evaluate an expression at the current execution point, click Evaluate Expression . • To advance to the next line in the code (without entering a method), click Step Over . • To advance to the first line inside a method call, click Step Into . • To advance to the next line outside the current method, click Step Out . • To continue running the app normally, click Resume Program
  • 15. TRACK OBJECT ALLOCATION facebook.com/ahmed.e.hassan 15 Android Studio lets you track objects that are being allocated on the Java heap and see which classes and threads are allocating these objects. This allows you to see the list of objects allocated during a period of interest. This information is valuable for assessing memory usage that can affect application performance. To track memory allocation of objects: 1. Start your app. 2. Click Android to open the Android DDMS tool window. 3. On the Android DDMS tool window, select the Devices | logcat tab. 4. Select your device from the dropdown list. 5. Select your app by its package name from the list of running apps. 6. Click Start Allocation Tracking 7. Interact with your app on the device. 8. Click Stop Allocation Tracking
  • 16. facebook.com/ahmed.e.hassan 16 TRACK OBJECT ALLOCATION Android Studio shows the objects that the system allocated with the following information: • Allocation order • Allocated class • Allocation size • Thread ID • Allocation method, class, and line number • Stack trace at the point of allocation
  • 17. CAPTURE SCREENSHOTS AND VIDEOS facebook.com/ahmed.e.hassan 17 Android Studio enables you to capture a screenshot or a short video of the device screen while your app is running. Screenshots and videos are useful as promotional materials for your app, and you can also attach them to bug reports that you send to your development team. To take a screenshot of your app: 1. Start your app. 2. Click Android to open the Android DDMS tool window. 3. Click Screen Capture on the left side of the Android DDMS tool window. 4. Optional: To add a device frame around your screenshot, enable the Frame screenshot option. 5. Click Save.
  • 18. facebook.com/ahmed.e.hassan 18 CAPTURE SCREENSHOTS AND VIDEOS To take a video recording of your app: 1. Start your app. 2. Click Android to open the Android DDMS tool window. 3. Click Screen Record on the left side of the Android DDMS tool window. 4. Click Start Recording. 5. Interact with your app. 6. Click Stop Recording. 7. Enter a file name for the recording and click OK.