mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-20 14:05:23 +01:00
Qt: add Android packaging support
Introduce an android directory under qt and allow one to package bitcoin-qt for Android by running make apk. Add bitcoin-qt Android build instructions.
This commit is contained in:
parent
d2a78ee928
commit
ebfb10cb75
16 changed files with 174 additions and 0 deletions
16
configure.ac
16
configure.ac
|
@ -734,6 +734,21 @@ case $host in
|
|||
*android*)
|
||||
dnl make sure android stays above linux for hosts like *linux-android*
|
||||
TARGET_OS=android
|
||||
case $host in
|
||||
*x86_64*)
|
||||
ANDROID_ARCH=x86_64
|
||||
;;
|
||||
*aarch64*)
|
||||
ANDROID_ARCH=arm64-v8a
|
||||
;;
|
||||
*armv7a*)
|
||||
ANDROID_ARCH=armeabi-v7a
|
||||
;;
|
||||
*i686*)
|
||||
ANDROID_ARCH=i686
|
||||
;;
|
||||
*) AC_MSG_ERROR("Could not determine Android arch") ;;
|
||||
esac
|
||||
;;
|
||||
*linux*)
|
||||
TARGET_OS=linux
|
||||
|
@ -1844,6 +1859,7 @@ AC_SUBST(HAVE_BUILTIN_PREFETCH)
|
|||
AC_SUBST(HAVE_MM_PREFETCH)
|
||||
AC_SUBST(HAVE_STRONG_GETAUXVAL)
|
||||
AC_SUBST(HAVE_WEAK_GETAUXVAL)
|
||||
AC_SUBST(ANDROID_ARCH)
|
||||
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/config.ini])
|
||||
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
|
||||
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
|
||||
|
|
|
@ -44,6 +44,7 @@ The following are developer notes on how to build Bitcoin Core on your native pl
|
|||
- [FreeBSD Build Notes](build-freebsd.md)
|
||||
- [OpenBSD Build Notes](build-openbsd.md)
|
||||
- [NetBSD Build Notes](build-netbsd.md)
|
||||
- [Android Build Notes](build-android.md)
|
||||
- [Gitian Building Guide (External Link)](https://github.com/bitcoin-core/docs/blob/master/gitian-building.md)
|
||||
|
||||
Development
|
||||
|
|
12
doc/build-android.md
Normal file
12
doc/build-android.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
ANDROID BUILD NOTES
|
||||
======================
|
||||
|
||||
This guide describes how to build and package the `bitcoin-qt` GUI for Android on Linux and macOS.
|
||||
|
||||
## Preparation
|
||||
|
||||
You will need to get the Android NDK and build dependencies for Android as described in [depends/README.md](../depends/README.md).
|
||||
|
||||
## Building and packaging
|
||||
|
||||
After the depends are built configure with one of the resulting prefixes and run `make && make apk` in `src/qt`.
|
|
@ -378,6 +378,20 @@ bitcoin_qt_clean: FORCE
|
|||
|
||||
bitcoin_qt : qt/bitcoin-qt$(EXEEXT)
|
||||
|
||||
APK_LIB_DIR = qt/android/libs/$(ANDROID_ARCH)
|
||||
QT_BASE_PATH = $(shell find ../depends/sources/ -maxdepth 1 -type f -regex ".*qtbase.*\.tar.xz")
|
||||
QT_BASE_TLD = $(shell tar tf $(QT_BASE_PATH) --exclude='*/*')
|
||||
|
||||
bitcoin_qt_apk: FORCE
|
||||
mkdir -p $(APK_LIB_DIR)
|
||||
cp $(dir $(CC))../sysroot/usr/lib/$(host_alias)/libc++_shared.so $(APK_LIB_DIR)
|
||||
tar xf $(QT_BASE_PATH) -C qt/android/src/ $(QT_BASE_TLD)src/android/jar/src --strip-components=5
|
||||
tar xf $(QT_BASE_PATH) -C qt/android/src/ $(QT_BASE_TLD)src/android/java/src --strip-components=5
|
||||
tar xf $(QT_BASE_PATH) -C qt/android/res/ $(QT_BASE_TLD)src/android/java/res --strip-components=5
|
||||
cp qt/bitcoin-qt $(APK_LIB_DIR)/libbitcoin-qt.so
|
||||
cd qt/android && gradle wrapper --gradle-version=6.6.1
|
||||
cd qt/android && ./gradlew build
|
||||
|
||||
ui_%.h: %.ui
|
||||
@test -f $(UIC)
|
||||
@$(MKDIR_P) $(@D)
|
||||
|
|
|
@ -7,3 +7,5 @@ check: FORCE
|
|||
$(MAKE) -C .. test_bitcoin_qt_check
|
||||
bitcoin-qt bitcoin-qt.exe: FORCE
|
||||
$(MAKE) -C .. bitcoin_qt
|
||||
apk: FORCE
|
||||
$(MAKE) -C .. bitcoin_qt_apk
|
||||
|
|
38
src/qt/android/AndroidManifest.xml
Normal file
38
src/qt/android/AndroidManifest.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest package="org.bitcoincore.qt" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
|
||||
<uses-sdk android:targetSdkVersion="24"/>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
||||
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
|
||||
|
||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Bitcoin Core">
|
||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
|
||||
android:name="org.bitcoincore.qt.BitcoinQtActivity"
|
||||
android:label="Bitcoin Core"
|
||||
android:icon="@drawable/bitcoin"
|
||||
android:screenOrientation="unspecified"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.arguments" android:value="-testnet"/>
|
||||
<meta-data android:name="android.app.lib_name" android:value="bitcoin-qt"/>
|
||||
<meta-data android:name="android.app.repository" android:value="default"/>
|
||||
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
|
||||
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
|
||||
<meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/>
|
||||
<meta-data android:name="android.app.background_running" android:value="true"/>
|
||||
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="true"/>
|
||||
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
52
src/qt/android/build.gradle
Normal file
52
src/qt/android/build.gradle
Normal file
|
@ -0,0 +1,52 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion androidCompileSdkVersion.toInteger()
|
||||
|
||||
buildToolsVersion androidBuildToolsVersion
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
manifest.srcFile 'AndroidManifest.xml'
|
||||
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
|
||||
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
|
||||
res.srcDirs = [qt5AndroidDir + '/res', 'res']
|
||||
resources.srcDirs = ['src']
|
||||
renderscript.srcDirs = ['src']
|
||||
assets.srcDirs = ['assets']
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
javaMaxHeapSize '4g'
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
}
|
||||
}
|
4
src/qt/android/gradle.properties
Normal file
4
src/qt/android/gradle.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
androidBuildToolsVersion=28.0.3
|
||||
androidCompileSdkVersion=28
|
||||
qt5AndroidDir=new File(".").absolutePath
|
||||
org.gradle.jvmargs=-Xmx4608M
|
BIN
src/qt/android/res/drawable-hdpi/bitcoin.png
Normal file
BIN
src/qt/android/res/drawable-hdpi/bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
src/qt/android/res/drawable-ldpi/bitcoin.png
Normal file
BIN
src/qt/android/res/drawable-ldpi/bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
src/qt/android/res/drawable-mdpi/bitcoin.png
Normal file
BIN
src/qt/android/res/drawable-mdpi/bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
src/qt/android/res/drawable-xhdpi/bitcoin.png
Normal file
BIN
src/qt/android/res/drawable-xhdpi/bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
BIN
src/qt/android/res/drawable-xxhdpi/bitcoin.png
Normal file
BIN
src/qt/android/res/drawable-xxhdpi/bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
src/qt/android/res/drawable-xxxhdpi/bitcoin.png
Normal file
BIN
src/qt/android/res/drawable-xxxhdpi/bitcoin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
29
src/qt/android/src/org/bitcoincore/qt/BitcoinQtActivity.java
Normal file
29
src/qt/android/src/org/bitcoincore/qt/BitcoinQtActivity.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package org.bitcoincore.qt;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
|
||||
import org.qtproject.qt5.android.bindings.QtActivity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BitcoinQtActivity extends QtActivity
|
||||
{
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
final File bitcoinDir = new File(getFilesDir().getAbsolutePath() + "/.bitcoin");
|
||||
if (!bitcoinDir.exists()) {
|
||||
bitcoinDir.mkdir();
|
||||
}
|
||||
|
||||
try {
|
||||
Os.setenv("QT_QPA_PLATFORM", "android", true);
|
||||
} catch (ErrnoException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
|
@ -466,6 +466,12 @@ int GuiMain(int argc, char* argv[])
|
|||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
||||
#if defined(QT_QPA_PLATFORM_ANDROID)
|
||||
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
|
||||
QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
QApplication::setAttribute(Qt::AA_DontUseNativeDialogs);
|
||||
#endif
|
||||
|
||||
BitcoinApplication app;
|
||||
QFontDatabase::addApplicationFont(":/fonts/monospace");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue