KC Blog

Sharing the Most Frequently Used Commands in Android App Development in 2022

3 min read
AndroidDev#ADB#Android#Brew#CLI#Development

  Preview

  • When I am developing, I always use brew to install some CLI tools.

    • Install brew

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  Android

  • How to install a test aab file

    • Install bundletool

      brew install bundletool

    • Switch to your aab file folder and convert it to an apk file

      bundletool build-apks --bundle=./app.aab --output=./app.apks

    • Install apk

      bundletool install-apks --apks=app.apks

  • Adb tool that I often use

    • Clear app data

    adb shell pm clear your.package.name

    • Delete app

    adb uninstall your.package.name

    • Search app package

    adb shell pm list packages | grep 'keyword'

    • Disable app

    adb shell pm disable-user 'your.package.name'

    • Open app

    adb shell am start -n your.package.name

    • Open app and go to a specific page

    adb shell am start -n your.package.name/your.assign.activity.path

    • Force-stop apps

    adb shell am force-stop your.package.name

    • Open Accessibility page

    adb shell am start -a android.settings.ACCESSIBILITY_SETTINGS

    • Open Device admin page

    adb shell am start -n android.app.extra.DEVICE_ADMIN

    • Set device owner

    adb -d shell dpm set-device-owner your.package.name/.your.admin.receivers.path

    • Remove device owner

    adb shell dpm remove-active-admin your.package.name/.your.admin.receivers.path

    • Dumpsys device owner info

    adb shell dumpsys device_policy

    • Grant app permissions

    adb shell "pm grant your.package.name android.permission.YourPermission && am force-stop elegant.access.aidltest"

    • Pull files

    adb pull /your/path

  bootloader

  • The steps to recover an Android phone using the official OTA
  1. Update bootloader
`fastboot flash bootloader bootloader-bullhead-xxxVersion.img`
  1. Reboot bootloader
`fastboot reboot-bootloader`
  1. Update radio
`fastboot flash radio radio-bullhead-xxxx-x.x.xx.x.xx.img`
  1. Reboot bootloader
`fastboot reboot-bootloader`
  1. Flash system
`fastboot flash system system.img`
  1. Flash vendor
`fastboot flash vendor vendor.img`
  1. Flash user data (This step will clear your internal storage.)
`fastboot flash userdata userdata.img`
  1. Flash boot
`fastboot flash boot boot.img`
  1. Flash recovery
`fastboot flash recovery recovery.img`
  1. Clear cache
`fastboot erase cache`
  1. Flash cache
`fastboot flash cache cache.img`
  1. Reboot android OS
`fastboot reboot`

  Git

  I prefer to use the git command line to control my repo instead of a git GUI tool.

  • Prevent your git graph from merging together and avoid committing after you send the CLI.

git merge --no-ff --no-commit hash

  • Edit your commit
`git commit --amend`
  • Rebase and sync your local repo with remote
`git pull origin --rebase`
  • Store/Recover/Show your unfinished work

git stash --include-untracked 、 git stash pop、 git list

  • See your local git info
`git config -l`
  • Basic git concepts
`git add , git commit , git push , git checkout, git pull , git cherry-pick, git branch , git remote...etc.`

  Others

  • See Java environment

/usr/libexec/java_home -V

Related Articles

Related content based on tags and categories

4 min read

Mastering Android Persistent Storage: Kotlin and Room Database Practical Tutorial

In this practical tutorial, we will delve into how to use Kotlin and Room to achieve persistent storage in Android applications. Whether you are a beginner or an experienced developer, this tutorial will provide you with practical knowledge and techniques to help you develop Android applications more effectively. Let's explore the powerful features of Kotlin and Room databases together and seamlessly integrate them into your next Android project!

📁 AndroidDev
#Android#Kotlin
4 min read

Android Kotlin: Recreating the Classic Snake Game, Playable in Less Than a Day!

In this tutorial, we will guide you step-by-step to create the classic Snake game, allowing you to fully experience the fun of game development during the learning process! Whether you are a beginner or an experienced developer, this hands-on tutorial will deepen your understanding of the Kotlin language and game development. Let's revisit this timeless game and create your own classic memories!

📁 AndroidDev
#Android#Kotlin