Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM debian:bookworm-slim

ARG ANDROID_COMMAND_LINE_TOOLS_VERSION=10406996
ARG ANDROID_COMMAND_LINE_TOOLS_SHA256=8919e8752979db73d8321e9babe2caedcc393750817c1a5f56c128ec442fb540
ARG GRADLE_VERSION=7.6.2
ARG GRADLE_SHA256=a01b6587e15fe7ed120a0ee299c25982a1eee045abd6a9dd5e216b2f628ef9ac

ENV ANDROID_SDK_ROOT=/opt/android-sdk \
NDK_ROOT=/opt/android-sdk/ndk/25.2.9519653 \
GRADLE_HOME=/opt/gradle/gradle-7.6.2 \
PATH=/opt/gradle/gradle-7.6.2/bin:/opt/android-sdk/cmdline-tools/latest/bin:/opt/android-sdk/build-tools/28.0.3:/opt/android-sdk/cmake/3.18.1/bin:${PATH}

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
ca-certificates \
curl \
default-jdk-headless \
git \
make \
ninja-build \
unzip \
&& rm -rf /var/lib/apt/lists/*

RUN curl --fail --location --show-error \
--output /tmp/command-line-tools.zip \
"https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_COMMAND_LINE_TOOLS_VERSION}_latest.zip" \
&& echo "${ANDROID_COMMAND_LINE_TOOLS_SHA256} /tmp/command-line-tools.zip" | sha256sum --check --strict \
&& mkdir -p "${ANDROID_SDK_ROOT}/cmdline-tools" \
&& unzip -q /tmp/command-line-tools.zip -d /tmp/android-command-line-tools \
&& mv /tmp/android-command-line-tools/cmdline-tools "${ANDROID_SDK_ROOT}/cmdline-tools/latest" \
&& rm -rf /tmp/command-line-tools.zip /tmp/android-command-line-tools \
&& (set +o pipefail; yes | sdkmanager --licenses >/dev/null) \
&& sdkmanager \
"build-tools;28.0.3" \
"build-tools;30.0.2" \
"cmake;3.18.1" \
"ndk;25.2.9519653" \
"platforms;android-32"

RUN curl --fail --location --show-error \
--output /tmp/gradle.zip \
"https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
&& echo "${GRADLE_SHA256} /tmp/gradle.zip" | sha256sum --check --strict \
&& mkdir -p /opt/gradle \
&& unzip -q /tmp/gradle.zip -d /opt/gradle \
&& rm /tmp/gradle.zip \
&& java --version \
&& gradle --version \
&& sdkmanager --version

WORKDIR /workspace

CMD ["bash", "-c", "gradle --no-daemon clean makeJar && dx --dex --output=monkeyq.jar monkey/build/libs/monkey.jar && sed 's/\\r$//' build_native.sh | sh"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@
## Build
The specific method of compiling Fastbot's apk file monkey.apk.

### Build with Docker

Docker can provide the required Java, Gradle, Android SDK, NDK, and CMake
versions without installing them on the host. From the repository root, build
the reusable builder image:

```shell
docker build -t fastbot-android-builder .
```

Then mount the repository and run the build:

```shell
docker run --rm -v "${PWD}:/workspace" fastbot-android-builder
```

The generated `monkeyq.jar` and native libraries under `libs/` are written to
the mounted repository. Rebuild the image after changing the tool versions in
the `Dockerfile`.

### Build with a local toolchain

The compilation of this project depends on gradle, so please install gradle first. Since there are many versions of gradle, the compatibility between different versions is different, so it is recommended to use sdkman to download and manage different versions of gradle. For specific installation and use of sdkman, please refer to: https://sdkman.io/

In short, to install sdkman, execute the following command in the shell:
Expand Down