This guide will walk you through the steps to build Bitcoin Core QML APKs using WSL Ubuntu 22.04 on Windows 11.
- Install WSL Ubuntu 22.04 on Windows 11. You can find a comprehensive guide here.
After installing Ubuntu, run the following commands to update it:
sudo apt update
sudo apt upgrade
Next, install the necessary Bitcoin Core dependencies with the following commands:
sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git
Also install the QML specific dependencies:
sudo apt install qtdeclarative5-dev qtquickcontrols2-5-dev
Follow the instructions below to install Android Studio and Android NDK on your system:
-
Install OpenJDK-11-JDK:
sudo apt install openjdk-11-jdk
-
Verify the installation by checking the java version:
java --version
-
Install Android Studio using Snap:
sudo snap install android-studio --classic
-
Run Android Studio:
android-studio
You can also follow the full installation guide for Android Studio and Android NDK here.
To install Android NDK:
- With a project open in Android Studio, click
Tools > SDK Manager
. - Click the
SDK Tools
tab. - Select the
NDK (Side by side)
andCMake
checkboxes. - Click
OK
. - A dialog box will tell you how much space the NDK package consumes on disk.
- Click
OK
. - When the installation is complete, click
Finish
.
You can find the full guide here.
Before you proceed, ensure you check your Android Device's hardware architecture. Use usbip and adb for this. Detailed guide can be found here.
-
Connect your Android device to your PC and enable USB debugging in Developer Options.
-
Once usbip is installed, list all USB devices connected to your PC by running the following command as Administrator in
cmd
:usbipd wsl list
-
Note down the
BUSID
of the device you want to connect to WSL. Then run the following command, replacing<busid>
with theBUSID
of your device:usbipd wsl attach --busid <busid>
-
Install adb:
sudo apt install adb
-
Check the hardware architecture of your device:
adb shell getprop ro.product.cpu.abi
-
Note down the architecture (arm64-v8a, armeabi-v7a, x86_64, x86).
-
Download Gradle 6.6.1:
VERSION=6.6.1 wget https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip -P /tmp
-
Extract the file:
sudo unzip -d /opt/gradle /tmp/gradle-${VERSION}-bin.zip
-
Set environment variables:
sudo nano /etc/profile.d/gradle.sh
-
Add the following lines to the file:
export GRADLE_HOME=/opt/gradle/gradle-${VERSION} export PATH=${GRADLE_HOME}/bin:${PATH}
-
Change the permissions:
sudo chmod +x /etc/profile.d/gradle.sh
-
Load the environment variables:
source /etc/profile.d/gradle.sh
-
Verify the installation by checking the Gradle version:
gradle -v
You can follow the full guide to install Gradle here.
Before building the APKs, run the following commands:
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
sudo bash -c "echo 0 > /proc/sys/fs/binfmt_misc/status" # Disable WSL support for Win32 applications.
More details on this step can be found here.
Now, you can build the APKs using the guide found here.
if you get an error like this:
global/qlogging:1296:13 n = backtrace(...
find the file qlogging.cpp (depends/.../work/.../global/) then you need to edit the function with the follwing:
static QStringList backtraceFramesForLogMessage(int frameCount)
{
QStringList result;
if (frameCount == 0)
return result;
#ifdef Q_OS_ANDROID
result.append(QStringLiteral("Stack trace generation not supported on Android."));
#else
// existing code here...
#endif
return result;
}
Also make sure to add the ANDROID_HOME variable to your .bashrc file:
nano ~/.bashrc
then add the following line to the end of the file:
export ANDROID_HOME=/home/<username>/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Once the APKs are built, install the debug version on your connected device using the following command from within the qt
directory:
adb install -r android/build/outputs/apk/debug/android-debug.apk