Skip to content

Commit 657eee8

Browse files
committed
doc: WSL-Ubuntu-Android Install Guide
1 parent 533a9fc commit 657eee8

File tree

1 file changed

+230
-1
lines changed

1 file changed

+230
-1
lines changed

doc/build-android.md

+230-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,233 @@ 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.
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 list
113+
```
114+
115+
If it doesn't say `SHARED` under the `STATE` collumn then run:
116+
```bash
117+
usbipd bind -b <busid>
118+
```
119+
120+
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:
121+
122+
```bash
123+
usbipd attach --busid <busid> --wsl
124+
```
125+
126+
4. Install adb:
127+
128+
```bash
129+
sudo apt install adb
130+
```
131+
132+
5. Check the hardware architecture of your device:
133+
134+
```bash
135+
adb shell getprop ro.product.cpu.abi
136+
```
137+
138+
6. Note down the architecture (arm64-v8a, armeabi-v7a, x86_64, x86).
139+
140+
### Step 6: Install Gradle
141+
142+
1. Download Gradle 6.6.1:
143+
144+
```bash
145+
VERSION=6.6.1
146+
wget https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip -P /tmp
147+
```
148+
149+
2. Extract the file:
150+
151+
```bash
152+
sudo unzip -d /opt/gradle /tmp/gradle-${VERSION}-bin.zip
153+
```
154+
155+
3. Set environment variables:
156+
157+
```bash
158+
sudo nano /etc/profile.d/gradle.sh
159+
```
160+
161+
4. Add the following lines to the file:
162+
163+
```bash
164+
export GRADLE_HOME=/opt/gradle/gradle-${VERSION}
165+
export PATH=${GRADLE_HOME}/bin:${PATH}
166+
```
167+
168+
5. Change the permissions:
169+
170+
```bash
171+
sudo chmod +x /etc/profile.d/gradle.sh
172+
```
173+
174+
6. Load the environment variables:
175+
176+
```bash
177+
source /etc/profile.d/gradle.sh
178+
```
179+
180+
7. Verify the installation by checking the Gradle version:
181+
182+
```bash
183+
gradle -v
184+
```
185+
186+
You can follow the full guide to install Gradle [here](https://linuxhint.com/installing_gradle_ubuntu/).
187+
188+
### Step 7: Build APKs
189+
190+
Before building the APKs, run the following commands:
191+
192+
```bash
193+
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
194+
sudo bash -c "echo 0 > /proc/sys/fs/binfmt_misc/status" # Disable WSL support for Win32 applications.
195+
```
196+
197+
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).
198+
199+
Now, you can build the APKs using the guide found [here](https://github.com/bitcoin-core/gui-qml/blob/main/doc/build-android.md).
200+
201+
if you get an error like this:
202+
203+
```bash
204+
global/qlogging:1296:13 n = backtrace(...
205+
```
206+
207+
find the file qlogging.cpp (depends/work/build/[host-platform-triplet]/qt/5.15.5-4750f35e363/qtbase/src/corelib/global/qlogging.cpp) then you need to edit the function with the following:
208+
209+
```
210+
static QStringList backtraceFramesForLogMessage(int frameCount)
211+
{
212+
QStringList result;
213+
if (frameCount == 0)
214+
return result;
215+
216+
#ifdef Q_OS_ANDROID
217+
result.append(QStringLiteral("Stack trace generation not supported on Android."));
218+
#else
219+
// existing code here...
220+
#endif
221+
return result;
222+
}
223+
```
224+
Also make sure to add the ANDROID_HOME variable to your .bashrc file:
225+
226+
```bash
227+
nano ~/.bashrc
228+
```
229+
then add the following line to the end of the file:
230+
231+
```bash
232+
export ANDROID_HOME=/home/<username>/Android/Sdk
233+
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
234+
```
235+
236+
Once the depends are built, configure them using the newly created configure file and run it from the root directory of the project i.e.:
237+
238+
```bash
239+
CONFIG_SITE=$PWD/depends/aarch64-linux-android/share/config.site ./configure --with-qml --disable-bench --disable-wallet
240+
```
241+
242+
The above will build the binaries without the wallet and benchmarking tools. You can also build the binaries with the wallet and benchmarking tools by removing the `--disable-bench` and `--disable-wallet` flags.
243+
244+
To build the APKs, run the following command from the `src/qt` directory of the project:
245+
246+
```bash
247+
make && make apk
248+
```
249+
250+
Once the APKs are built, install the debug version on your connected device using the following command from within the `src/qt` directory:
251+
252+
```bash
253+
adb install -r android/build/outputs/apk/debug/android-debug.apk
254+
```

0 commit comments

Comments
 (0)