-
-
Save 0xAIGC/251304bd4b633c0745917ccca0f5d7db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
AAPT="/path/to/android-sdk/build-tools/23.0.3/aapt" | |
DX="/path/to/android-sdk/build-tools/23.0.3/dx" | |
ZIPALIGN="/path/to/android-sdk/build-tools/23.0.3/zipalign" | |
APKSIGNER="/path/to/android-sdk/build-tools/26.0.1/apksigner" # /!\ version 26 | |
PLATFORM="/path/to/android-sdk/platforms/android-19/android.jar" | |
echo "Cleaning..." | |
rm -rf obj/* | |
rm -rf src/com/example/helloandroid/R.java | |
echo "Generating R.java file..." | |
$AAPT package -f -m -J src -M AndroidManifest.xml -S res -I $PLATFORM | |
echo "Compiling..." | |
javac -d obj -classpath src -bootclasspath $PLATFORM -source 1.7 -target 1.7 src/com/example/helloandroid/MainActivity.java | |
javac -d obj -classpath src -bootclasspath $PLATFORM -source 1.7 -target 1.7 src/com/example/helloandroid/R.java | |
echo "Translating in Dalvik bytecode..." | |
$DX --dex --output=classes.dex obj | |
echo "Making APK..." | |
$AAPT package -f -m -F bin/hello.unaligned.apk -M AndroidManifest.xml -S res -I $PLATFORM | |
$AAPT add bin/hello.unaligned.apk classes.dex | |
echo "Aligning and signing APK..." | |
$APKSIGNER sign --ks mykey.keystore bin/hello.unaligned.apk | |
$ZIPALIGN -f 4 bin/hello.unaligned.apk bin/hello.apk | |
if [ "$1" == "test" ]; then | |
echo "Launching..." | |
adb install -r bin/hello.apk | |
adb shell am start -n com.example.helloandroid/.MainActivity | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment