android-make-helloworld/Makefile

50 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

2020-11-08 19:18:31 +00:00
JAVA="/strg/bin/jdk8/"
# Android SDK utils
SDK="/opt/android-sdk"
BUILD_TOOLS="$(SDK)/build-tools/30.0.2"
PLATFORM="${SDK}/platforms/android-23"
# Project folders
BUILD="build"
Hello.apk: keystore.jks $(BUILD)/Hello.unsigned.apk
$(BUILD_TOOLS)/apksigner sign --ks keystore.jks \
--ks-key-alias androidKey --ks-pass pass:android \
--key-pass pass:android --out $(BUILD)/Hello.apk \
$(BUILD)/Hello.aligned.apk
keystore.jks:
keytool -genkeypair -keystore keystore.jks -alias androidkey \
-validity 10000 -keyalg RSA -keysize 2048 \
-storepass android -keypass android
$(BUILD)/Hello.aligned.apk: $(BUILD)/Hello.unsigned.apk
$(PLATFORM)/Hello.unsigned.apk $(BUILD)/Hello.aligned.apk
$(BUILD)/Hello.unsigned.apk: $(BUILD)/apk/classes.dex
"$(BUILD_TOOLS)/aapt" package -f -M AndroidManifest.xml -S res/ \
-I "$(PLATFORM)/android.jar" \
-F "$(BUILD)/Hello.unsigned.apk" build/apk
$(BUILD_TOOLS)/zipalign -f -p 4 \
$(BUILD)/Hello.unsigned.apk build/Hello.aligned.apk
$(BUILD)/apk/classes.dex: $(BUILD)/obj/MainActivity.class
$(BUILD_TOOLS)/dx --dex --output=build/apk/classes.dex build/obj
$(BUILD)/obj/MainActivity.class: $(BUILD)/gen/su/fai/hello/R.java
$(JAVA)/bin/javac -source 1.7 -target 1.7 -bootclasspath "$(JAVA)/jre/rt.jar" \
-classpath "$(PLATFORM)/android.jar" -d build/obj \
$(BUILD)/gen/su/fai/hello/R.java java/su/fai/hello/MainActivity.java
$(BUILD)/gen/su/fai/hello/R.java: AndroidManifest.xml res/* $(BUILD)
$(BUILD_TOOLS)/aapt package -f -mJ $(BUILD)/gen -S res\
-M AndroidManifest.xml -I "$(PLATFORM)/android.jar"
$(BUILD):
mkdir -p $(BUILD)/gen $(BUILD)/obj $(BUILD)/apk
clean:
rm -rf $(BUILD)