Notes on how to build and run an Android application from the command line

As a brief note to self, this is how I compiled/built an Android application (APK) from the MacOS command line and then ran it in an emulator. I include both my application- and system-specific notes, as well as the more generic commands I found at this URL:

- build a “debug apk”
    - COMMAND: `gradlew assembleDebug`
    - This creates an APK named module_name-debug.apk in 
    - MINE: ./app/build/outputs/apk/app-debug.apk
- need to start an emulator
    - COMMAND: emulator -avd avd_name
    - MINE:    emulator -avd Pixel_2_API_27_Oreo_8.1_
        - HOW TO LIST EMULATORS: `emulator -list-avds`
        - emulator dir: ~/Library/Android/sdk/emulator
- install onto the emulator:
    - COMMAND: adb install path/to/your_app.apk
    - MINE:    adb install ./app/build/outputs/apk/app-debug.apk


  • In a dev environment you build a debug APK (that’s also signed)
  • On a Mac/macOS system, the Android SDK is in the directory shown (~/Library/Android/sdk), assuming that it was installed with Android Studio
  • The adb command won’t work if you have more than one emulator running

If you ever want/need to build an Android application from the command line, I hope these notes are helpful.