Skip to content

Commit 72f3c44

Browse files
committed
WSL-Ubuntu-Android Install Guide
1 parent 67150ef commit 72f3c44

File tree

1 file changed

+212
-1
lines changed

1 file changed

+212
-1
lines changed

doc/build-android.md

+212-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,215 @@ This is an example command for a default build with no disabled dependencies:
2222

2323
## Building and packaging
2424

25-
After the depends are built configure with one of the resulting prefixes and run `make && make apk` in `src/qt`.
25+
After the depends are built configure with one of the resulting prefixes and run `make && make apk` in `src/qt`.
26+
27+
# Bitcoin Core WSL Ubuntu Android QML GUI
28+
29+
This guide will walk you through the steps to build Bitcoin Core QML APKs using WSL Ubuntu 22.04 on Windows 11.
30+
31+
## Prerequisites
32+
33+
1. Install WSL Ubuntu 22.04 on Windows 11. You can find a comprehensive guide [here](https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview).
34+
35+
## Installation Steps
36+
37+
### Step 1: Update WSL Ubuntu 22.04
38+
39+
After installing Ubuntu, run the following commands to update it:
40+
41+
```bash
42+
sudo apt update
43+
sudo apt upgrade
44+
```
45+
46+
### Step 2: Install Bitcoin Core Dependencies
47+
48+
Next, install the necessary Bitcoin Core dependencies with the following commands:
49+
50+
```bash
51+
sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git
52+
```
53+
54+
Also install the QML specific dependencies:
55+
56+
```bash
57+
sudo apt install qtdeclarative5-dev qtquickcontrols2-5-dev
58+
```
59+
60+
### Step 3: Install Android Studio
61+
62+
Follow the instructions below to install Android Studio and Android NDK on your system:
63+
64+
1. Install OpenJDK-11-JDK:
65+
66+
```bash
67+
sudo apt install openjdk-11-jdk
68+
```
69+
70+
2. Verify the installation by checking the java version:
71+
72+
```bash
73+
java --version
74+
```
75+
76+
3. Install Android Studio using Snap:
77+
78+
```bash
79+
sudo snap install android-studio --classic
80+
```
81+
82+
4. Run Android Studio:
83+
84+
```bash
85+
android-studio
86+
```
87+
88+
You can also follow the full installation guide for Android Studio and Android NDK [here](https://linuxhint.com/install-android-studio-ubuntu22-04/).
89+
90+
### Step 4: Install Android NDK
91+
92+
To install Android NDK:
93+
94+
1. With a project open in Android Studio, click `Tools > SDK Manager`.
95+
2. Click the `SDK Tools` tab.
96+
3. Select the `NDK (Side by side)` and `CMake` checkboxes.
97+
4. Click `OK`.
98+
5. A dialog box will tell you how much space the NDK package consumes on disk.
99+
6. Click `OK`.
100+
7. When the installation is complete, click `Finish`.
101+
102+
You can find the full guide [here](https://developer.android.com/studio/projects/install-ndk).
103+
104+
### Step 5: Check Android Device Architecture
105+
106+
Before you proceed, ensure you check your Android Device's hardware architecture. Use usbip and adb for this. Detailed guide can be found [here](https://www.xda-developers.com/wsl-connect-usb-devices-windows-11/).
107+
108+
1. Connect your Android device to your PC and enable USB debugging in Developer Options.
109+
2. Once usbip is installed, list all USB devices connected to your PC by running the following command as Administrator in `cmd`:
110+
111+
```bash
112+
usbipd wsl list
113+
```
114+
115+
3. Note down the `BUSID` of the device you want to connect to WSL. Then run the following command, replacing `<busid>` with the `BUSID` of your device:
116+
117+
```bash
118+
usbipd wsl attach --busid <busid>
119+
```
120+
121+
4. Install adb:
122+
123+
```bash
124+
sudo apt install adb
125+
```
126+
127+
5. Check the hardware architecture of your device:
128+
129+
```bash
130+
adb shell getprop ro.product.cpu.abi
131+
```
132+
133+
6. Note down the architecture (arm64-v8a, armeabi-v7a, x86_64, x86).
134+
135+
### Step 6: Install Gradle
136+
137+
1. Download Gradle 6.6.1:
138+
139+
```bash
140+
VERSION=6.6.1
141+
wget https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip -P /tmp
142+
```
143+
144+
2. Extract the file:
145+
146+
```bash
147+
sudo unzip -d /opt/gradle /tmp/gradle-${VERSION}-bin.zip
148+
```
149+
150+
3. Set environment variables:
151+
152+
```bash
153+
sudo nano /etc/profile.d/gradle.sh
154+
```
155+
156+
4. Add the following lines to the file:
157+
158+
```bash
159+
export GRADLE_HOME=/opt/gradle/gradle-${VERSION}
160+
export PATH=${GRADLE_HOME}/bin:${PATH}
161+
```
162+
163+
5. Change the permissions:
164+
165+
```bash
166+
sudo chmod +x /etc/profile.d/gradle.sh
167+
```
168+
169+
6. Load the environment variables:
170+
171+
```bash
172+
source /etc/profile.d/gradle.sh
173+
```
174+
175+
7. Verify the installation by checking the Gradle version:
176+
177+
```bash
178+
gradle -v
179+
```
180+
181+
You can follow the full guide to install Gradle [here](https://linuxhint.com/installing_gradle_ubuntu/).
182+
183+
### Step 7: Build APKs
184+
185+
Before building the APKs, run the following commands:
186+
187+
```bash
188+
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
189+
sudo bash -c "echo 0 > /proc/sys/fs/binfmt_misc/status" # Disable WSL support for Win32 applications.
190+
```
191+
192+
More details on this step can be found [here](https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md#compiling-with-windows-subsystem-for-linux).
193+
194+
Now, you can build the APKs using the guide found [here](https://github.com/bitcoin-core/gui-qml/blob/main/doc/build-android.md).
195+
196+
if you get an error like this:
197+
198+
```bash
199+
global/qlogging:1296:13 n = backtrace(...
200+
```
201+
202+
find the file qlogging.cpp (depends/.../work/.../global/) then you need to edit the function with the following:
203+
204+
```
205+
static QStringList backtraceFramesForLogMessage(int frameCount)
206+
{
207+
QStringList result;
208+
if (frameCount == 0)
209+
return result;
210+
211+
#ifdef Q_OS_ANDROID
212+
result.append(QStringLiteral("Stack trace generation not supported on Android."));
213+
#else
214+
// existing code here...
215+
#endif
216+
return result;
217+
}
218+
```
219+
Also make sure to add the ANDROID_HOME variable to your .bashrc file:
220+
221+
```bash
222+
nano ~/.bashrc
223+
```
224+
then add the following line to the end of the file:
225+
226+
```bash
227+
export ANDROID_HOME=/home/<username>/Android/Sdk
228+
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
229+
```
230+
231+
232+
Once the APKs are built, install the debug version on your connected device using the following command from within the `qt` directory:
233+
234+
```bash
235+
adb install -r android/build/outputs/apk/debug/android-debug.apk
236+
```

0 commit comments

Comments
 (0)