This note documents the exact small-app workflow that was verified against the local LineageOS VM over adb.
- Device:
127.0.0.1:5555 - OS:
LineageOS 23.1/Android 16 - ABI:
arm64-v8a - Demo package:
com.example.smalihello
- project:
experiments/smali-hello/ - manifest:
experiments/smali-hello/AndroidManifest.xml - Java source:
experiments/smali-hello/src/com/example/smalihello/MainActivity.java - build script:
experiments/smali-hello/build-smali-demo.sh - generated smali:
experiments/smali-hello/smali-src/smali/...
The working setup used these tools:
java,javacaapt,d8,zipalign,apksignerapktooladb
Expected SDK paths in this repo's environment:
- SDK root:
/Users/password9090/android-sdk - build-tools:
34.0.0 - platform jar:
platforms/android-34/android.jar
From repo root:
chmod +x experiments/smali-hello/build-smali-demo.sh
./experiments/smali-hello/build-smali-demo.shExpected output:
- final APK:
experiments/smali-hello/build/smali-signed.apk
What the script does:
- packages resources with
aapt - compiles Java with
javac - creates
classes.dexwithd8 - adds
classes.dexinto the base APK - aligns and signs the APK
- decompiles it with
apktool - rebuilds the APK from the generated smali tree
- aligns and signs the smali-rebuilt APK
Check that smali files exist:
find experiments/smali-hello/smali-src -type f -name '*.smali' | headKey file:
experiments/smali-hello/smali-src/smali/com/example/smalihello/MainActivity.smali
Also verify the signed APK contains classes.dex:
unzip -l experiments/smali-hello/build/smali-signed.apk | grep classes.dexMake sure the VM is visible first:
adb devices -l
adb connect 127.0.0.1:5555Install the smali-built APK:
adb -s 127.0.0.1:5555 install -r experiments/smali-hello/build/smali-signed.apkVerify the package is installed:
adb -s 127.0.0.1:5555 shell pm list packages | grep com.example.smalihelloadb -s 127.0.0.1:5555 shell am start -W -n com.example.smalihello/.MainActivityOptional runtime verification:
adb -s 127.0.0.1:5555 shell dumpsys activity activities \
| egrep 'mResumedActivity|topResumedActivity|com.example.smalihello'After the first build, edit files under:
experiments/smali-hello/smali-src/smali/
Typical target:
experiments/smali-hello/smali-src/smali/com/example/smalihello/MainActivity.smali
After editing smali, rebuild/sign/install manually:
apktool b experiments/smali-hello/smali-src -o experiments/smali-hello/build/smali-unsigned.apk
/Users/password9090/android-sdk/build-tools/34.0.0/zipalign -f 4 \
experiments/smali-hello/build/smali-unsigned.apk \
experiments/smali-hello/build/smali-aligned.apk
/Users/password9090/android-sdk/build-tools/34.0.0/apksigner sign \
--ks experiments/smali-hello/build/debug.keystore \
--ks-key-alias androiddebugkey \
--ks-pass pass:android \
--key-pass pass:android \
--out experiments/smali-hello/build/smali-signed.apk \
experiments/smali-hello/build/smali-aligned.apk
adb -s 127.0.0.1:5555 install -r experiments/smali-hello/build/smali-signed.apkadb -s 127.0.0.1:5555 uninstall com.example.smalihelloaapt packageneeded-m, otherwiseR.javawas not generated.aapt addhad to run from the build directory with a relative path, otherwiseclasses.dexwas skipped.d8was happiest when given explicit.classfiles plus an existing output directory.- The current manifest targets SDK 34, but the VM runs Android 16 / SDK 36 and installed the APK fine.