Skip to content

Instantly share code, notes, and snippets.

@Fire-
Last active November 19, 2025 13:23
Show Gist options
  • Select an option

  • Save Fire-/d02ab6c54614064cbd27fa789caae9c6 to your computer and use it in GitHub Desktop.

Select an option

Save Fire-/d02ab6c54614064cbd27fa789caae9c6 to your computer and use it in GitHub Desktop.
I wanted to work on SmartTube on my phone without polluting my env with old jdk

Portable Toolchain Setup

This is written under the presumption you're using an aarch64 device like a phone or an nvidia shield to build artifacts, and the SmartTube project root is your current PWD.

If you're using a different system architecture, you'll need to substitute aarch64 jdk/sdk builds for your current arch


Portable JDK Installations

JDK 14 (Gradle builds)

SmartTube requires JDK 14 or older for unspecified reasons ( "newer could cause app crash" )

  1. Download the ARM64 archive locally:
    curl -L -o .jdk14.tar.gz \
      "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.2%2B12/OpenJDK14U-jdk_aarch64_linux_hotspot_14.0.2_12.tar.gz"
  2. Extract somewhere writable (e.g. /tmp on Termux/Android environments avoids symlink restrictions):
    tar -xf .jdk14.tar.gz -C /tmp
    mv /tmp/jdk-14.0.2+12 /tmp/jdk14
  3. Point Gradle commands at the portable JDK when building:
    JAVA_HOME=/tmp/jdk14 \
    ANDROID_SDK_ROOT="$PWD/.android-sdk" \
    bash ./gradlew :common:compileStstableDebugJavaWithJavac

JDK 17 (sdkmanager)

sdkmanager requires Java 17, so we need to keep a separate JDK 17 install alongside the JDK 14 toolchain.

  1. Download and extract:
    curl -L -o jdk17.tar.gz \
      "https://download.oracle.com/java/17/archive/jdk-17.0.12_linux-aarch64_bin.tar.gz"
    tar -xf jdk17.tar.gz -C /tmp
    mv /tmp/jdk-17.0.12 /tmp/jdk17
  2. Use this JDK only when invoking the Android command line tools:
    JAVA_HOME=/tmp/jdk17 \
    PATH="$JAVA_HOME/bin:$PATH" \
    ./cmdline-tools/latest/bin/sdkmanager --list

Portable Android SDK Setup

  1. Download the Android command line tools archive into the project root:
    curl -L -o commandlinetools-linux.zip \
      "https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip"
  2. Extract into .android-sdk/cmdline-tools/latest:
    mkdir -p .android-sdk/cmdline-tools
    unzip commandlinetools-linux.zip -d .android-sdk/cmdline-tools
    mv .android-sdk/cmdline-tools/cmdline-tools .android-sdk/cmdline-tools/latest
  3. Install required packages with the portable JDK 17:
    JAVA_HOME=/tmp/jdk17 \
    PATH="$JAVA_HOME/bin:$PATH" \
    .android-sdk/cmdline-tools/latest/bin/sdkmanager \
      "platforms;android-33" \
      "build-tools;30.0.3" \
      "platform-tools"
  4. Accept licenses once:
    JAVA_HOME=/tmp/jdk17 \
    PATH="$JAVA_HOME/bin:$PATH" \
    yes | .android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses

Project Configuration

Create or update local.properties in the project root so Gradle resolves the portable SDK:

sdk.dir=.android-sdk

Usage

  • Building the project:
    JAVA_HOME=/tmp/jdk14 \
    ANDROID_SDK_ROOT="$PWD/.android-sdk" \
    bash ./gradlew assembleStstableDebug
  • Managing SDK packages:
    JAVA_HOME=/tmp/jdk17 \
    PATH="$JAVA_HOME/bin:$PATH" \
    .android-sdk/cmdline-tools/latest/bin/sdkmanager --update

Keep both JDK archives within the repository (or a sibling directory) so the setup remains portable across machines. Update the paths above if you relocate the extracted folders.

Targeting Specific ABIs

How to build SmartTube APKs for specific CPU architectures (e.g. NVIDIA Shield’s 64-bit ARM).

This document also assumes you're using a portable toolchain configuration like the one described in portable-android-toolchain.md


Configure ABI Filters

Edit the android {} block (typically in app/build.gradle) to restrict or split APKs per ABI:

android {
    defaultConfig {
        ndk {
            abiFilters "arm64-v8a"        // primary target
            // add "armeabi-v7a", "x86", etc. as needed
        }
    }

    splits {
        abi {
            enable true
            universalApk false             // one APK per ABI
            include "arm64-v8a"           // add more ABIs if desired
        }
    }
}
  • abiFilters limits native libraries packaged into the APK.
  • splits.abi generates separate APKs per architecture. Use universalApk true if you also want a catch-all build.

Build Commands

JAVA_HOME=/tmp/jdk14 \
ANDROID_SDK_ROOT="$PWD/.android-sdk" \
bash ./gradlew app:assembleStstableDebug

Outputs appear under app/build/outputs/apk/ststableDebug/. When splits are enabled, Gradle provides one APK per ABI (*-arm64-v8a.apk, etc.).

Android App Bundle Option

To generate a bundle with ABI splits handled at install time:

JAVA_HOME=/tmp/jdk14 \
ANDROID_SDK_ROOT="$PWD/.android-sdk" \
bash ./gradlew app:bundleStstableRelease

The resulting .aab in app/build/outputs/bundle/StstableRelease/ can be sideloaded with bundletool or uploaded to distribution platforms.


Verifying ABI Contents

Use aapt or bundletool to confirm packaged ABIs:

.android-sdk/build-tools/30.0.3/aapt dump badging app/build/outputs/apk/ststableDebug/app-ststableDebug-arm64-v8a.apk | grep native-code

Expect output similar to native-code: 'arm64-v8a'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment