Alpine Android

repository·master·Indexed 19 days ago

https://github.com/alvr/alpine-android

Docker images containing Android SDK components and JDK runtimes optimized for Alpaquita Linux. Provides two variants: Alpine Android (including build-tools and platforms) and Alpine Android Base. Supports multiple JDK versions (8, 11, 17, 21) mapped to specific Android Gradle Plugin (AGP) versions and offers API-level specific tags.

Tokens
3.1K
Snippets
7
Records
11
Agent score
16%

What's inside alpine-android

  1. Understand Alpine Android versioning

    master

    For tags that specify a JDK version, you can use date-based versioning to revert to a specific release. The tag format is:

    android-{API_LEVEL}-{JDK_VERSION}-v{YYYY.MM.DD}

    Example: android-30-jdk11-v2021.01.01

    Note: Versioning is not available for alpine-android-base images.

  2. Understand the difference between Alpine Android and Alpine Android Base

    master

    The two image variants differ by the inclusion of build tools:

    • Alpine Android: Includes build-tools and platforms;android versions.
    • Alpine Android Base: Contains only the common core (95% shared with the full image). Use this as a base for custom images to simplify maintenance.
  3. Run an Alpine Android container

    master

    Run a new container interactively. The container will open in the /home/android directory, and all included tools will be available in the PATH.

    Note: Using the --rm flag will delete the container once it is closed. To persist the container after closing, remove the --rm flag.

    DockerHub

    docker run --rm -it alvrme/alpine-android-base:<tag>

    GHCR

    docker run --rm -it ghcr.io/alvr/alpine-android-base:<tag>

    Quay

    docker run --rm -it quay.io/alvr/alpine-android-base:<tag>
    docker run --rm -it alvrme/alpine-android:<tag>
  4. Use Alpine Android as a base image in a Dockerfile

    master

    To create a custom image, use the Alpine Android images in your FROM instruction. Replace <tag> with a valid version tag.

    DockerHub

    FROM alvrme/alpine-android-base:<tag>
    FROM alvrme/alpine-android:<tag>

    GHCR

    FROM ghcr.io/alvr/alpine-android-base:<tag>
    FROM ghcr.io/alvr/alpine-android:<tag>

    Quay

    FROM quay.io/alvr/alpine-android-base:<tag>
    FROM quay.io/alvr/alpine-android:<tag>
    FROM alvrme/alpine-android-base:<tag>
  5. Choose the correct Alpine Android image variant

    master

    Alpine Android images are based on bellsoft/liberica-runtime-container using Alpaquita Linux (glibc). Choose your JDK variant based on the Android Gradle Plugin (AGP) version you are using:

    JDK versionAGP version
    8< 7.0.0
    11>= 7.0.0 && < 8.0.0
    17>= 8.0.0
    21>= 8.2.1
  6. Extend from Alpine Android Base

    master

    You can use the Alpine Android Docker images as a base for your own Dockerfiles. Once you have set the base image, you can install additional Android or Alpine packages directly within your Dockerfile.

    To install Android packages, use the sdkmanager command:

    RUN sdkmanager <list-of-packages>

    To install Alpine packages, use the apk package manager:

    RUN apk add --no-cache <list-of-packages>
    RUN sdkmanager <list-of-packages>
    
    RUN apk add --no-cache <list-of-packages>
  7. Pull Alpine Android images from registries

    master

    You can pull the alpine-android-base or alpine-android images from three different registries. Replace <tag> with a valid version tag.

    DockerHub

    Use the alvrme/ prefix.

    GitHub Container Registry (GHCR)

    Use the ghcr.io/alvr/ prefix.

    Quay

    Use the quay.io/alvr/ prefix.

    # DockerHub
    docker pull alvrme/alpine-android-base:<tag>
    docker pull alvrme/alpine-android:<tag>
    
    # GHCR
    docker pull ghcr.io/alvr/alpine-android-base:<tag>
    docker pull ghcr.io/alvr/alpine-android:<tag>
    
    # Quay
    docker pull quay.io/alvr/alpine-android-base:<tag>
    docker pull quay.io/alvr/alpine-android:<tag>
  8. Reference: Android SDK components in Alpine Android images

    master

    The following table lists the common Android SDK components and their locations across various Android version images. Note that specific versions of build-tools and platforms will vary depending on the specific Android version image you are using.

    | Path | Version | Description | Location |
    |---|---|---|---|
    | build-tools;[version] | [version] | Android SDK Build-Tools | build-tools/[version]/ |
    | extras;google;instantapps | 1.9.0 | Google Play Instant Development SDK | extras/google/instantapps/ |
    | patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4/ |
    | platform-tools | 37.0.0 | Android SDK Platform-Tools | platform-tools/ |
    | platforms;android-[api] | [version] | Android SDK Platform [api] | platforms/android-[api]/ |
  9. Reference Android Base image content

    master

    The alpine-android-base image contains the following components:

    PathVersionDescription
    extras;google;instantapps1.9.0Google Play Instant Development SDK
    patcher;v41SDK Patch Applier v4
    platform-tools37.0.0Android SDK Platform-Tools
  10. Reference the Alpine Android image tags

    master

    Tags are constructed using the API level and the JDK version suffix.

    Base Image Tags:

    • JDK8: jdk8, latest-jdk8
    • JDK11: jdk11, latest-jdk11
    • JDK17: jdk17, latest, latest-jdk17
    • JDK21: jdk21, latest-jdk21

    Android API Level Tags: To target a specific Android API level, use the format android-{API_LEVEL}-{JDK_SUFFIX}.

    Examples:

    • Android 13 (API 33) with JDK 11: android-33-jdk11
    • Android 14 (API 34) with JDK 17: android-34-jdk17
    • Android 15 (API 35) with JDK 21: android-35-jdk21
    | API level         | JDK8                               | JDK11                                                | JDK17                               | JDK21                                |
    |-------------------|------------------------------------|------------------------------------------------------|-------------------------------------|-------------------------------------|
    | Base Image        | `jdk8` `latest-jdk8`               | `jdk11`, `latest-jdk11`                              | `jdk17`, `latest`, `latest-jdk17`   | `jdk21`, `latest-jdk21`             |
    | Android 9.0 (28)  | `android-28-jdk8`                  | `android-28`, `android-28-jdk11`                     | `android-28-jdk17`                             | `android-28-jdk21`                  |
    | Android 10 (29)   | `android-29-jdk8`                  | `android-29`, `android-29-jdk11`                     | `android-29-jdk17`                             | `android-29-jdk21`                  |
    | Android 11 (30)   | `android-30-jdk8`                  | `android-30`, `android-30-jdk11`                     | `android-30-jdk17`                             | `android-30-jdk21`                  |
    | Android 12 (31)    | `android-31-jdk8`                  | `android-31`, `android-31-jdk11`                     | `android-31-jdk17`                             | `android-31-jdk21`                  |
    | Android 12L (32)  | `android-32-jdk8`                  | `android-32`, `android-32-jdk11`                     | `android-32-jdk17`                             | `android-32-jdk21`                  |
    | Android 13 (33)    | `android-33-jdk8`                  | `android-33`, `android-33-jdk11`                     | `android-33-jdk17`                             | `android-33-jdk21`                  |
    | Android 14 (34)   | `android-34-jdk8`                  | `android-34`, `android-34-jdk11`                     | `android-34-jdk17`                             | `android-34-jdk21`                  |
    | Android 15 (35)   | `android-35-jdk8`                  | `android-35`, `android-35-jdk11`                     | `android-35-jdk17`                             | `android-35-jdk21`                  |
    | Android 16 (36.0) | `android-36-jdk8`                  | `android-36`, `android-36-jdk11`                     | `android-36-jdk17`                             | `android-36-jdk21`                  |
    | Android 16 (36.1) | `android-36.1-jdk8`                | `android-36.1`, `android-36.1-jdk11`                 | `android-36.1-jdk17`                           | `android-36.1-jdk21`                 |
    | Android 17 (37.0) | `android-37.0-jdk8`, `latest-jdk8` | `android-37.0`, `android-37.0-jdk11`, `latest-jdk11` | `android-37.0-jdk17`, `latest`, `latest-jdk17` | `android-37.0-jdk21`, `latest-jdk21` |
    | Android 17 (37.1) | `android-37.1-jdk8`                | `android-37.1`, `android-37.1-jdk11`                 | `android-37.1-jdk17`                           | `android-37.1-jdk21`                 |
  11. Use the `extras` command to install utilities

    master

    The base image includes an extras command to install optional utilities that are not included by default. These are executed using the syntax extras <command>.

    Install Fastlane

    Fastlane automates iOS and Android tasks like screenshots and provisioning.

    • To install the latest version: extras fastlane
    • To install a specific version: extras fastlane <version>

    Install NDK and CMAKE

    To implement native code (C/C++), use the extras ndk command. By default, this installs the latest available versions (e.g., NDK 29.0.14206865 and CMAKE 4.1.2).

    To specify custom versions, use the following flags:

    • --ndk | -n <version>
    • --cmake | -c <version>
    extras fastlane <version>
    extras ndk [--ndk | -n <version>] [--cmake | -c <version>]