Android device debugging via USB
July 28, 2025 ยท View on GitHub
What
You can get crash logs from your Android device with USB debugging and adb.
Why
Crash logs, aka backtraces, make it sigificantly easier to fix the bug that caused the crash.
How
Further documentation
Howtogeek page about administrator privileges
Things you will need
Androiddevice, aka phone or tabletWindows,Linux, ormacOScomputerUSBcable to connect between the computer and the Android device, likelyUSB-A to CorUSB-C to C- The correct
ADB(Android Debug Bridge) for your operating system
Steps
- Enabling
Developer optionson yourAndroiddevice - Enable
USB debuggingon yourAndroiddevice - Connect the
USBcable between the computer andAndroiddevice - Download correct copy of
adbfor your operating system, see below - Unzip
adbzip - Unlock the
Android device
Windows
- Open a command prompt with
administrator privilegeson the computer cdto directory withadb- Run
adb.exe shell
Linux or macOS
-
Open a terminal window on the computer
-
cdto directory withadb -
Run
sudo ./adb shelland enter your password -
Allow the debugging when prompted
-
Type
exitand hit enter
Windows
- Run
adb logcat | findstr AndroidRuntime
Linux or macOS
-
Run
sudo adb logcat | grep AndroidRuntime -
Look at the timestamps on the left, and copy the block of lines that have very close timestamps
-
Paste it into a new Github issue
-
Create the new Github issue
-
Disable
USB debugginginDeveloper optionson yourAndroiddevice after you are done
Example of the crash log
02-08 17:36:07.739 25025 25025 E AndroidRuntime: FATAL EXCEPTION: main
02-08 17:36:07.739 25025 25025 E AndroidRuntime: Process: me.edgan.redditslide, PID: 25025
02-08 17:36:07.739 25025 25025 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RelativeLayout.setVisibility(int)' on a null object reference
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at me.edgan.redditslide.Activities.MainActivity$AsyncNotificationBadge.onPostExecute(MainActivity.java:5145)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at me.edgan.redditslide.Activities.MainActivity$AsyncNotificationBadge.onPostExecute(MainActivity.java:5071)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.os.AsyncTask.finish(AsyncTask.java:771)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:109)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:232)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.os.Looper.loop(Looper.java:317)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8787)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
02-08 17:36:07.739 25025 25025 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:871)
ADB downloads
Instructions from the documentation for enabling Developer options
Device Setting
Google Pixel Settings > About phone > Build number
Samsung Galaxy S8 and later Settings > About phone > Software information > Build number
LG G6 and later Settings > About phone > Software info > Build number
HTC U11 and later Settings > About > Software information > More > Build number or Settings > System > About phone > Software information > More > Build number
OnePlus 5T and later Settings > About phone > Build number
Enabling USB debugging on your device
Before you can use the debugger and other tools, you need to enable USB debugging, which allows Android Studio and other SDK tools to recognize your device when connected via USB.
Enable USB debugging in the device system settings under Developer options. You can find this option in one of the following locations, depending on your Android version:
Android 9 (API level 28) and higher: Settings > System > Advanced > Developer Options > USB debugging