Skip to content

Instantly share code, notes, and snippets.

@kyudorimj
Last active October 21, 2021 14:00
Show Gist options
  • Save kyudorimj/37e8832d11abef06ab34b14c3346d19f to your computer and use it in GitHub Desktop.
Save kyudorimj/37e8832d11abef06ab34b14c3346d19f to your computer and use it in GitHub Desktop.
ADB IN GIT BASH TERMINAL | WINDOWS

APK ANDROID DEBUG BRIDGE (ADB) IN GIT BASH TERMINAL

This guide only covers the install, uninstall, and debug in adb.

What you need:

  • USB Lightning Cable
  • Android Phone

Prerequisites:

Steps:

  1. Extract / unzip the platform tools zip file that you downloaded.
  2. Open the extracted files and find the platform-tools folder.
  3. Navigate inside the folder and open the Git Bash Terminal from the current directory by right clicking and choosing Git Bash Here.
  4. Connect your phone to the computer using the USB lightning cable. Make sure to accept the USB debugging prompt.

Install APKs

If you want to install the app into your phone run the command

./adb install path/to/apk/Appname.apk

Note: You need to specify the path/to/apk/ on where the apk file is located.
To make it not complicated, you can just paste your app inside platform-tools directory and run ./adb install Appname.apk


Uninstall APKs

Uninstalling the apk installed on your phone is as easy as installing it. You just need to know the package name of the app that you need to uninstall.

./adb uninstall com.org.testapp

Note: You need to specify the package name (com.org.testapp) of the app. The com.org is the domain name and testapp is the name of the app. If you are not quite sure what's the package name of the app that is installed on your phone, you check it on the app's settings.


Debug APKs

Debugging the apk is done to see the process or services running underlying the installed application.
It is done using logcat command which prints logs of the running applicaiton.

./adb logcat

You can also filter logcat if you only want to see the logs from your application. It is mainly done using pid support in adb. To filter logcat to show logs of your application only, simply run:

./adb logcat --pid=`adb shell pidof -s com.org.testapp`

Note: com.org.testapp should be replaced with your application package name.

References

Android Developer: Logcat command-line tool
StackOverFlow: Filter LogCat to get only the messages from My Application in Android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment