summaryrefslogtreecommitdiff
path: root/doc/note/setup/setup-android-env.txt
diff options
context:
space:
mode:
Diffstat (limited to 'doc/note/setup/setup-android-env.txt')
-rw-r--r--doc/note/setup/setup-android-env.txt85
1 files changed, 85 insertions, 0 deletions
diff --git a/doc/note/setup/setup-android-env.txt b/doc/note/setup/setup-android-env.txt
new file mode 100644
index 0000000..0008c16
--- /dev/null
+++ b/doc/note/setup/setup-android-env.txt
@@ -0,0 +1,85 @@
+#
+# Tools for Android development.
+#
+# HINT: Since JDK-8 is no longer available, we have to add clutter to
+# apksigner command. Eg:
+# apksigner -J-add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
+# -J-add-opens=java.base/sun.security.x509=ALL-UNNAMED \
+# -J-add-opens=java.base/sun.security.pkcs=ALL-UNNAMED
+#
+# Refs:
+# - [Clean Android HelloWorld Tutorial](https://www.hanshq.net/command-line-android.html)
+# - [List of available versions](https://dl.google.com/android/repository/repository-11.xml)
+#
+set -e
+
+### Made for debian 10 (alias buster)
+true \
+ && PKGS_TO_ADD="curl unzip openjdk-17-jdk-headless aapt apksigner zipalign adb android-sdk-platform-tools-common" \
+ && SUDO=sudo \
+ && PKGINIT="$SUDO apt update" \
+ && PKGADD="$SUDO apt install -y --no-install-recommends" \
+ && PKGCLEAN="$SUDO apt clean" \
+ && PLATFORM_VERSION="24" \
+ && BUILD_TOOLS_VERSION="34.0.0" \
+ && CMDLINETOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip" \
+ && BUILD_TOOLS_URL="https://dl.google.com/android/repository/build-tools_r25-linux.zip" \
+ && PLATFORM_URL="https://dl.google.com/android/repository/platform-${PLATFORM_VERSION:?}_r02.zip" \
+ && NDK_URL="https://dl.google.com/android/repository/android-ndk-r26b-linux.zip" \
+ && BUILD_TOOLS_ZIP="$(basename "${BUILD_TOOLS_URL:?}")" \
+ && PLATFORM_ZIP="$(basename "${PLATFORM_URL:?}")" \
+ && NDK_ZIP="$(basename "${NDK_URL:?}")" \
+ \
+ && $PKGINIT \
+ && $PKGADD $PKGS_TO_ADD \
+ && `# Cmdline tools` \
+ && (cd /var/tmp && curl -sSLO "${CMDLINETOOLS_URL:?}") \
+ && if test -x /tmp/cmdline-tools; then echo >&2 "[ERROR] /tmp/cmdline-tools already exists"; false; fi \
+ && (cd /tmp && unzip /var/tmp/$(basename "${CMDLINETOOLS_URL:?}") >/dev/null) \
+ && $SUDO mkdir /usr/lib/android-sdk/cmdline-tools \
+ && $SUDO mkdir /usr/lib/android-sdk/cmdline-tools/latest \
+ && (cd /tmp/cmdline-tools && tar --owner=0 --group=0 -c bin lib source.properties) | (cd /usr/lib/android-sdk/cmdline-tools/latest && $SUDO tar x) \
+ && `# Build Tools` \
+ && (cd /var/tmp && curl -sSL "${BUILD_TOOLS_URL:?}" -o "${BUILD_TOOLS_ZIP:?}") \
+ && mkdir "/tmp/${BUILD_TOOLS_ZIP%.*}" \
+ && (cd "/tmp/${BUILD_TOOLS_ZIP%.*}" && unzip "/var/tmp/${BUILD_TOOLS_ZIP:?}") \
+ && (cd "/tmp/${BUILD_TOOLS_ZIP%.*}" && tar --owner=0 --group=0 -c *) \
+ | (cd /usr/lib/android-sdk/build-tools && $SUDO tar x) \
+ && $SUDO find /usr/lib/android-sdk/build-tools -type d -exec chmod 755 {} + \
+ && `# Those for some reason are broken (wrong linker) so use the debian variant.` \
+ && (cd /usr/lib/android-sdk/build-tools/android* && $SUDO rm aapt zipalign) \
+ && `# Platform` \
+ && (cd /var/tmp && curl -sSL "${PLATFORM_URL:?}" -o "${PLATFORM_ZIP:?}") \
+ && if test -x /tmp/android*; then echo >&2 '[ERROR] /tmp/android* already exists'; false; fi \
+ && (cd /tmp && unzip "/var/tmp/${PLATFORM_ZIP:?}" >/dev/null) \
+ && $SUDO mkdir /usr/lib/android-sdk/platforms \
+ && (cd /tmp && mv android-* "android-${PLATFORM_VERSION:?}") \
+ && (cd /tmp && tar --owner=0 --group=0 -c "android-${PLATFORM_VERSION:?}") \
+ | (cd /usr/lib/android-sdk/platforms && $SUDO tar x) \
+ && $SUDO find /usr/lib/android-sdk/platforms/android-* -type d -exec chmod o+rx {} + \
+ && $SUDO find /usr/lib/android-sdk/platforms/android-* -type f -exec chmod o+r {} + \
+ && `# Environ` \
+ && printf >>~/.profile '%s\n' \
+ "PATH=/usr/lib/android-sdk/build-tools/debian:\$PATH" \
+ "PATH=\"$(ls -d /usr/lib/android-sdk/build-tools/android-*):\$PATH\"" \
+ "PATH=\"/usr/lib/android-sdk/platform-tools:\$PATH\"" \
+ "PATH=\"$(ls -d /usr/lib/android-sdk/build-tools/android-*):\$PATH\"" \
+ "CLASSPATH=$(ls -d /usr/lib/android-sdk/build-tools/android-*/lib/dx.jar)" \
+ "LD_LIBRARY_PATH=$(ls -d /usr/lib/android-sdk/build-tools/android-*/lib64):\$LD_LIBRARY_PATH" \
+ "export PATH" \
+ "export CLASSPATH" \
+ "export LD_LIBRARY_PATH" \
+ && `# NDK` \
+ && (cd /var/tmp && curl -sSL "${NDK_URL:?}" -o "${NDK_ZIP:?}") \
+ && mkdir "/tmp/${NDK_ZIP%.*}" \
+ && (cd "/tmp/${NDK_ZIP%.*}" && unzip "/var/tmp/${NDK_ZIP:?}") \
+ && `# TODO may worth throw away some of that garbage before moving it into place` \
+ && (cd "/tmp/${NDK_ZIP%.*}" && tar --owner=0 --group=0 -c android-ndk-*) \
+ | (cd "/usr/lib" && $SUDO tar x) \
+ && $SUDO ln -s /usr/lib/android-ndk-* "/usr/lib/android-ndk" \
+ && `# Cleanup` \
+ && $PKGCLEAN \
+ && rm -rf /tmp/* 2>/dev/null || true \
+ && printf '\n Done :)\n\n Logout and login to get your new environ from ~/.profile\n\n' \
+ && true
+