Porrumentzio commented on issue #1 at Coffee / hello-world-debian-android

Porrumentzio
2020-11-09T18:52:29Z

This is already solved. Works both on Arch as on Manjaro. Two things are needed:

Install

These Android-development packages (for this repo) from AUR: android-sdk, android-platform-23, android-sdk-build-tools and android-sdk-platform-tools

JDK8, for example jdk8-openjdk and make

Change Makefile

The path to JDK must be changed depending on which package you use and where you download it from. You can search for the location using Octopi>the-package>Files or any other way.

JAVA="/usr/lib/jvm/java-8-openjdk/"

# 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)