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
Go to the
home
directory and install the related tools
Install cmdline package
Unzip the file
Set PATEH environment variable
Set ANDROID_SDK_ROOT environment variable
Install android ndk21.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
Set JAVA_HOME environment variable
Execute gradle and build the apk
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.
Step 3: Copy the Gradle archive to the generated directory. Make sure to replace 9l9tetv7ltxvx3i8an4pb86ye
with your own directory name.
Step 4: Execute the build process again. This time, the build process will be much faster!
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
Go tot the
remote-desktop-clients
directory and build bVNC-app
5. Compile gallery_fde
Back to the
home
directory and get the source code of gallery-fde
Go to the
gallery-fde
and change its mode
Build app
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.
$AOSP_TOP_DIR
represents the top-level directory of the AOSP source tree.