apkc is a bare-bones Android app build system. It lets you build simple native Android apps in APK or AAB format without entire Android IDE. It does a subset of what Android Gradle plugin does. This makes it quick and runs with low resources. apkc is mostly suitable for learning purposes.
- Base project has zero dependencies. APK is <20 KB.
- Builds base project in <3 seconds.
- Can use external JAR libraries.
- Can use external native shared libs built with C/Go/Rust etc.
- Code completion can be setup in VSCode or other editors.
- Install JDK and Android SDK and make sure to have
ANDROID_HOME
andJAVA_HOME
env variables setup. - Download
apkc
from Github releases for your OS/ARCH. - Use
doctor
command to verify all the paths are correct.
$ apkc doctor
[doctor] java /usr/local/opt/openjdk@11/
[doctor] javac /usr/local/opt/openjdk@11/bin/javac
[doctor] jarsigner /usr/local/opt/openjdk@11/bin/jarsigner
[doctor] sdk /Users/ajinasokan/Library/Android/sdk
[doctor] aapt /Users/ajinasokan/Library/Android/sdk/build-tools/30.0.3/aapt
[doctor] aapt2 /Users/ajinasokan/Library/Android/sdk/build-tools/30.0.3/aapt2
[doctor] d8 /Users/ajinasokan/Library/Android/sdk/build-tools/30.0.3/d8
[doctor] zipalign /Users/ajinasokan/Library/Android/sdk/build-tools/30.0.3/zipalign
[doctor] android jar /Users/ajinasokan/Library/Android/sdk/platforms/android-30/android.jar
- Create a hello world project.
$ apkc create myapp
Package name (com.myapp): com.ajinasokan.myapp
App name (My App): Hello World
- Build APK and run in connected device. Logs from app will be streamed after successful run.
$ cd myapp
$ apkc build
[build] compiling res/layout/main.xml
[build] compiling res/values/styles.xml
[build] bundling resources
[build] compiling java files
[build] bundling classes and jars
[build] bundling native libs
[build] no native libs
[build] signing apk
[build] running zipalign
[apkc] finished in 1.580135483s
$ apkc run
[run] installing in device(serialabcxyz)
[run] launching main activity
07-06 11:23:29.894 22390 22390 I libc : SetHeapTaggingLevel: tag level set to 0
07-06 11:23:29.933 22390 22390 E jinasokan.myap: Not starting debugger since process cannot load the jdwp agent.
....
....
To build APK with custom key store run apkc build --keystore "/path/to/keystore.jks" --storepass "password" --keyalias "alias"
.
To build AAB run apkc build --aab
. Output file will be at build/app.{apk/aab}
.
You can add external jar dependencies to myapp/jar
directory and native libs to myapp/lib
in appropriate architecture sub directories.
You can add raw assets to myapp/assets
directory.
- Install Java extension
- Add
android.jar
path fromdoctor
command output toreferencedLibraries
list of your workspace VSCode settings file.myapp/.vscode/settings.json
{
"java.project.referencedLibraries": [
"<pathtosdk>/platforms/android-30/android.jar"
]
}
- You could also add other external jar file dependencies
apkc was born in 2016 as a bash script for some of my experiments. It then evolved into a Makefile and was used for production builds of one of my apps. Since the Play Store started enforcing AAB files for publishing I had to move away from apkc. This project is a rewrite of the Makefile, without the incremental compilation. Incremental compilation is in the todo list.