Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt: Add Android packaging support #17227

Merged
merged 5 commits into from Mar 24, 2021
Merged

Conversation

icota
Copy link
Contributor

@icota icota commented Oct 23, 2019

bitcoin-qt
This PR is the third and final piece of the basic Android support puzzle - it depends on #16110 and is related to #16883. It introduces an android directory under qt and a simple way to build an Android package of bitcoin-qt:

  1. Build depends for Android as described in the README
  2. Configure with one of the resulting prefixes
  3. Run make && make apk in src/qt

The resulting APK files will be in android/build/outputs/apk. You can install them manually or with adb. One can also open the android directory in Android Studio for that integrated development and debugging experience. BitcoinQtActivity is your starting point.

Under the hood makefile apk target:

  1. Renames the bitcoin-qt binary to libbitcoin-qt.so and copies it over to a folder under android/libs depending on which prefix and corresponding ABI bitcoin-qt was built for
  2. Takes libc++_shared.so from the Android NDK and puts in the same place. It must be included in the APK
  3. Extracts Qt for Android Java support files from the qtbase archive in depends/sources to android/src

There is also just a tiny bit of ifdef'd code to make the Qt Widgets menus usable. It's not pretty but it works and is a stepping stone towards #16883.

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 23, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj laanwj added the GUI label Oct 24, 2019
@laanwj
Copy link
Member

laanwj commented Oct 24, 2019

Concept ACK, nice !

@icota
Copy link
Contributor Author

icota commented Nov 4, 2019

Rebased, squashed, added instructions under doc and updated the first comment to reflect that #16110 has been merged.

doc/package-android.md Outdated Show resolved Hide resolved
@luke-jr
Copy link
Member

luke-jr commented Nov 4, 2019

This PR is the third and final piece of the basic Android support puzzle

IMO final would be a gitian descriptor ;)

@adamjonas
Copy link
Member

@icota Friendly ping for a rebase.

@icota
Copy link
Contributor Author

icota commented May 2, 2020

Thank you @adamjonas. Rebased.

@maflcko
Copy link
Member

maflcko commented May 2, 2020

@icota Could you pull in maflcko@a0b441b to shave off a few kB off of the compressed images?

@icota
Copy link
Contributor Author

icota commented May 3, 2020

Absolutely. Thanks @MarcoFalke

@maflcko
Copy link
Member

maflcko commented May 3, 2020

Oh, you'll have to squash it. Otherwise git will keep track of both versions, thus doubling the size.

@icota
Copy link
Contributor Author

icota commented May 3, 2020

Done.

@BlockMechanic
Copy link
Contributor

Awesome, will test this out.

@jonasschnelli
Copy link
Contributor

utACK a818b2c

@maflcko
Copy link
Member

maflcko commented May 29, 2020

Concept ACK. Not sure how this can be tested in ci. I guess it needs the android dev kit?

@icota
Copy link
Contributor Author

icota commented May 30, 2020

Yep it needs the SDK. Travis seems to support this.

@maflcko
Copy link
Member

maflcko commented May 31, 2020

Unfortunately (or luckily) we can't use travis' packages. We use our own ci setup in ./ci.

The sdkmanager is a zip file that can be downloaded, though. And then a one-liner like

$ANDROID_HOME/tools/bin/sdkmanager --sdk_root=$ANDROID_HOME "platform-tools" "platforms;android-28" "ndk-bundle"

should do the rest.

@jonasschnelli
Copy link
Contributor

I'd like to give this a try in the main branch (even without CI support). If it gets unmaintained, a revert is likely.
Anyone with Android experience willing to test this @Sjors, @hebasto, @promag, @greenaddress?

@maflcko
Copy link
Member

maflcko commented Mar 24, 2021

cr ACK 246774e

@laanwj
Copy link
Member

laanwj commented Mar 24, 2021

Code review ACK 246774e

@laanwj laanwj merged commit 23b1560 into bitcoin:master Mar 24, 2021
@ghost
Copy link

ghost commented Mar 24, 2021

#16883 is an attempt to make the GUI a bit more modern and usable but it's parked for now as I can't find the time to work on it.

@icota Thanks for working on this. Its merged :) #16883 looks interesting except one comment from @promag , my younger brother is also good with Android development but Kotlin. Will share things with him after testing.

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 24, 2021
@ryanofsky
Copy link
Contributor

ryanofsky commented Mar 24, 2021

Seeing CI failures in ARM64 Android APK [bionic] build that might be related to this:

https://cirrus-ci.com/task/5511109198217216?command=ci#L4420
https://cirrus-ci.com/task/5967779246374912?command=ci#L4426

make[1]: Entering directory '/tmp/cirrus-ci-build/src'
tar: --exclude=*/*: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: --exclude=*/*: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: --exclude=*/*: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
mkdir -p qt/android/libs/arm64-v8a
cp /tmp/cirrus-ci-build/depends/SDKs/android/ndk/21.1.6352462/toolchains/llvm/prebuilt/linux-x86_64/bin//../sysroot/usr/lib/aarch64-linux-android/libc++_shared.so qt/android/libs/arm64-v8a
tar xf  -C qt/android/src/ src/android/jar/src --strip-components=5
tar: -C: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Makefile:15443: recipe for target 'bitcoin_qt_apk' failed

@icota
Copy link
Contributor Author

icota commented Mar 25, 2021

@ryanofsky Yes, and this line is the culprit:

QT_BASE_PATH = $(shell find ../depends/sources/ -maxdepth 1 -type f -regex ".*qtbase.*\.tar.xz")

Is Cirrus perhaps wiping depends/sources from time to time?

@achow101
Copy link
Member

achow101 commented Mar 25, 2021

Is Cirrus perhaps wiping depends/sources from time to time?

I'm able to reproduce a similar error locally so I don't think it is a cirrus issue.

@icota
Copy link
Contributor Author

icota commented Mar 25, 2021

I can't reproduce locally (unless I manually delete sources) but I'm seeing a pattern on the latest runs:

fails when run last:
https://github.com/bitcoin/bitcoin/pull/21392/checks
https://github.com/bitcoin/bitcoin/pull/16545/checks
https://github.com/bitcoin/bitcoin/pull/19460/checks

succeds otherwise:
https://github.com/bitcoin/bitcoin/pull/21422/checks
https://github.com/bitcoin/bitcoin/pull/21526/checks
https://github.com/bitcoin/bitcoin/pull/17227/checks

I'm drawing a blank here and I am also fine with disabling the CI APK build for the time being.

@icota
Copy link
Contributor Author

icota commented Mar 28, 2021

Trying to fix the issue in #21537

@icota
Copy link
Contributor Author

icota commented Mar 28, 2021

Fixed by @MarcoFalke in #21541

@@ -378,6 +378,20 @@ bitcoin_qt_clean: FORCE

bitcoin_qt : qt/bitcoin-qt$(EXEEXT)

APK_LIB_DIR = qt/android/libs/$(ANDROID_ARCH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the content of the qt/android directory be a subject of the cleanup in make clean or make distclean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should 👍

kwvg added a commit to kwvg/dash that referenced this pull request Nov 24, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Nov 25, 2021
Comment on lines +16 to +19
final File bitcoinDir = new File(getFilesDir().getAbsolutePath() + "/.bitcoin");
if (!bitcoinDir.exists()) {
bitcoinDir.mkdir();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code prevents the Intro dialog from showing at the first startup. Is it intended? If yes, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I don't remember why I did this. Did you try without it? Maybe the dialog was showing incorrectly?

I didn't at the time but I realise now that this makes using external storage impossible. Possibly related to bitcoin-core/gui#496

@hebasto
Copy link
Member

hebasto commented Dec 5, 2021

After bumping Qt to 5.15.2 (#23489) this stuff seems required to be updated to work properly.
Massive changes were done in Qt 5.14 (e.g., qt/qtbase@5bb178c).

@icota Could you have a look into this please?

@hebasto
Copy link
Member

hebasto commented Dec 6, 2021

After bumping Qt to 5.15.2 (#23489) this stuff seems required to be updated to work properly. Massive changes were done in Qt 5.14 (e.g., qt/qtbase@5bb178c).

@icota Could you have a look into this please?

https://www.kdab.com/qt-for-android-better-than-ever-before/ seems related.

@icota
Copy link
Contributor Author

icota commented Dec 12, 2021

Thanks for letting me know @hebasto. Attempting to fix the issues in bitcoin-core/gui#504

kwvg added a commit to kwvg/dash that referenced this pull request Dec 12, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Jan 12, 2022
kwvg added a commit to kwvg/dash that referenced this pull request Feb 7, 2022
kwvg added a commit to kwvg/dash that referenced this pull request Feb 17, 2022
kwvg added a commit to kwvg/dash that referenced this pull request Feb 18, 2022
kwvg added a commit to kwvg/dash that referenced this pull request Apr 25, 2022
kwvg added a commit to kwvg/dash that referenced this pull request Apr 25, 2022
kwvg added a commit to kwvg/dash that referenced this pull request Apr 26, 2022
UdjinM6 added a commit to dashpay/dash that referenced this pull request Apr 26, 2022
kwvg pushed a commit to kwvg/dash that referenced this pull request Oct 16, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Dec 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet