Build Android APK
a multi-core X86 host with a minimum requirement of 16GB of RAM and a minimum disk size of 512GB.
1. Install Ubuntu and Run the Container
Install docker
sudo apt install docker.io
Pull ubuntu:22.04 from the docker repository
sudo docker pull ubuntu:22.04
Run ubuntu:22.04
sudo docker run -it --name ubuntu_build_apk ubuntu:22.04
2. Install cmdline tools和ndk
Update the list of package
apt update
Go to the
home
directory and install the related tools
cd ~ && apt install wget zip openjdk-11-jre git openjdk-17-jre -y
Install cmdline package
wget https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip
Unzip the file
unzip commandlinetools-linux-10406996_latest.zip
Set PATEH environment variable
export PATH=$PATH:/root/cmdline-tools/bin/
Set ANDROID_SDK_ROOT environment variable
mkdir /root/sdk_root && export ANDROID_SDK_ROOT=/root/sdk_root/
Install android ndk21.1.6352462
sdkmanager --sdk_root=/root/sdk_root/ 'ndk;21.1.6352462'
If you encounter the prompt "Accept?(y/N):" during the command execution, please press 'y'.
3. Build Systemui APK
Get the source code and go to the
boringdroidsystemui
directory
git clone https://gitee.com/openfde/boringdroidsystemui && cd boringdroidsystemui
Set JAVA_HOME environment variable
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/
Execute gradle and build the apk
./gradlew build
Helpful tip: During the process of building an APK using this command, the Gradle installation package will be downloaded first. If the build process is taking a long time, you can follow the four steps below to speed up this step.
Step 1: Execute the command ./gradlew build
, which will generate a directory. In the example given below, it is /root/.gradle/wrapper/dists/gradle-7.6-bin/9l9tetv7ltxvx3i8an4pb86ye/
. Please locate the folder generated in your own gradle-7.6-bin
directory.
Step 2: Manually download the Gradle installation package.9l9tetv7ltxvx3i8an4pb86ye
with your own directory name.
wget https://services.gradle.org/distributions/gradle-7.6-bin.zip
Step 3: Copy the Gradle archive to the generated directory. Make sure to replace 9l9tetv7ltxvx3i8an4pb86ye
with your own directory name.
cp gradle-7.6-bin.zip /root/.gradle/wrapper/dists/gradle-7.6-bin/9l9tetv7ltxvx3i8an4pb86ye/
Step 4: Execute the build process again. This time, the build process will be much faster!
./gradlew build
Note: Due to the requirement of sdkmanager to run on Java 17 and the limitation of compiling APKs on Java 11, it is necessary to reset JAVA_HOME to Java 11. Compiling with Java 17 will result in the following error.
Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens http://java.io " to unnamed module @71cff6a8.
After compilation is complete, you can find the BoringdroidSystemUI.apk
file in the app/build/outputs/apk/release
directory.
4. Build FdeVNC APK
Back to the
home
directory and get the source code of fde-vnc
cd ~ && git clone https://gitee.com/openfde/remote-desktop-clients
Go tot the
remote-desktop-clients
directory and build bVNC-app
cd remote-desktop-clients && ./gradlew :bVNC-app:assembleRelease -PVersionName="1.0.5"
5. Compile gallery_fde
Back to the
home
directory and get the source code of gallery-fde
cd ~ && git clone https://gitee.com/openfde/gallery_fde
Go to the
gallery-fde
and change its mode
cd gallery_fde && chmod +x gradlew
Build app
./gradlew build -PappVersion=1.0.6
6. Copy APK to AOSP
Open a new Linux shell terminal and copy the compiled APK files from sections 3.3 and 3.4 out of the container.
docker cp ubuntu_build_apk:/root/boringdroidsystemui/app/build/outputs/apk/release/BoringdroidSystemUI.apk $AOSP_TOP_DIR/vendor/prebuilts/bdapps/bin/BoringdroidSystemUI.apk
docker cp ubuntu_build_apk:/root/remote-desktop-clients/bVNC-app/build/outputs/apk/release/FdeVncClient.apk $AOSP_TOP_DIR/device/openfde/fde/fde_vnc/
$AOSP_TOP_DIR
represents the top-level directory of the AOSP source tree.