Commands and options
Every way to run android_scaffold, every option, and the plain Gradle and adb commands it runs for you.
Usage
python3 android_scaffold.py <source> [options]
<source> is a folder of .kt files, searched recursively, or a single .kt file. Rerunning any command is incremental: the existing project is reused and only changed files are copied.
Common commands
python3 android_scaffold.py <source> # generate or refresh the project
python3 android_scaffold.py <source> --build-apk # and build the APK
python3 android_scaffold.py <source> --run # and install and launch
python3 android_scaffold.py <source> --watch # and reload on every save
python3 android_scaffold.py <source> --list-emulators # list installed emulators
python3 android_scaffold.py <source> --start-emulator # boot the first emulator
python3 android_scaffold.py <source> --start-emulator Pixel_8_Pro_API_33
Options
| Option | Default | Description |
|---|---|---|
-o, --output | ./android_build | Where the generated project goes. You can also open it in Android Studio. |
-n, --name | ThumbInventory | App name shown under the launcher icon. |
--apk-dir | apk/ next to the source | Where a copy of the built APK is placed. |
--build-apk | off | Build the debug APK. |
--run | off | Build, install and launch on a phone or emulator. |
--watch | off | Like --run, then rebuild, reinstall and relaunch whenever a .kt file changes. See live reload. |
--start-emulator [AVD] | off | Boot an emulator, optionally by name, and wait until it has finished booting. |
--list-emulators | off | List installed Android Virtual Devices and exit. |
Which device is used
For --run and --watch, a phone or emulator that adb already sees is used as is. Otherwise the named AVD, or the first installed one, is booted and the script waits for it to report that boot has completed.
The same steps by hand
After every run the script prints a cheat sheet of the commands it uses, filled in with your paths. They are ordinary Android tooling, so you can run them yourself or in CI:
emulator -list-avds
emulator -avd Pixel_8_Pro_API_33 &
adb wait-for-device
cd android_build
./gradlew assembleDebug
./gradlew installDebug
adb shell am start -n com.example.tapcounter/.MainActivity
On Windows use .\gradlew.bat. The debug APK is written to android_build/app/build/outputs/apk/debug/app-debug.apk.
Reading the output
| Prefix | Meaning |
|---|---|
[*] | A step is starting, or information about the project. |
[+] | A step succeeded. |
[!] | Something failed. The message says what to do next; see also troubleshooting. |
Environment variables
| Variable | Used for |
|---|---|
ANDROID_HOME | Location of the Android SDK. Checked first. |
ANDROID_SDK_ROOT | Older name for the same thing. Checked second. |
JAVA_HOME | The JDK Gradle runs on. Must be 17 or newer. |