make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/home/user/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin NO_QT=1 NO_WALLET=1
depends: Add Android NDK support #16110
pull icota wants to merge 13 commits into bitcoin:master from icota:add-android-to-depends changing 16 files +191 −7-
icota commented at 1:47 am on May 28, 2019: contributorThis allows one to build the dependencies with the Android SDK and goes towards fixing #11844. It has been tested to work with:
-
icota renamed this:
Scripts and tools: Add Android NDK support to depends
depends: Add Android NDK support
on May 28, 2019 -
DrahtBot added the label Build system on May 28, 2019
-
DrahtBot added the label Docs on May 28, 2019
-
in depends/packages/openssl.mk:60 in 468eb9c69b outdated
56@@ -57,6 +57,7 @@ $(package)_config_opts_riscv64_linux=linux-generic64 57 $(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc 58 $(package)_config_opts_x86_64_mingw32=mingw64 59 $(package)_config_opts_i686_mingw32=mingw 60+$(package)_config_opts_android=linux-generic64
luke-jr commented at 2:22 am on May 28, 2019:What if it’s being built for ARM32, x86, or some other platform entirely?
BlockMechanic commented at 9:30 am on August 10, 2019:So this :- https://github.com/openssl/openssl/pull/2229 would not work ?
BlockMechanic commented at 3:00 pm on August 15, 2019:Actualy, i think this does it for both https://github.com/ruslo/hunter/pull/814/files. Is it worth creating a patch ?
greenaddress commented at 9:07 pm on October 14, 2019:Google has not deprecated 32bit apps afaik. Link? It has deprecated gcc in favour of clang that’s correct. Most emulators images are still 32 bit AFAIK.
greenaddress commented at 9:50 pm on October 14, 2019:If you are referring to https://android-developers.googleblog.com/2019/01/get-your-apps-ready-for-64-bit.html they want people to support 64 but they explicitly state that 32 bit support is here to stay.
icota commented at 6:32 am on October 15, 2019:My bad, you are right, they haven’t deprecated 32-bit. But let’s continue this discussion in the main comments.laanwj commented at 9:33 am on May 28, 2019: memberVery cool, concept ACKfanquake commented at 1:51 pm on May 28, 2019: memberConcept ACKfanquake commented at 1:52 pm on May 28, 2019: member@greenaddress You might be interested in taking a look at this?laanwj commented at 12:55 pm on June 13, 2019: memberWould be awesome if someone who is building bitcoin core for Android would review and test this. This change is pretty minimal.
I’d love to have a
arm64-android
gitian build at some point so that software such as abcore can include that instead of having to build it out of band with additional patch-sets.greenaddress commented at 3:02 pm on June 23, 2019: contributorGoogle now mandates that all ndk based application ship all 4 binaries armv7a/aarch64/x86/amd64 - should be tested on all (and ideally added to the CI to prevent breakage). Specifically you may have some issue on 32 bit without some extra flags. See https://GitHub.com/GreenAddress/bitcoin_ndk for what’s currently required to build core with NDK
Haven’t reviewed the PR patches yet, will have a look later
fanquake commented at 5:34 am on June 24, 2019: memberI had a quick test of this. Installed the Mac ndk from https://developer.android.com/ndk/downloads/.
Couldn’t get Boost 1.70.0 to build correctly, but reverting to 1.64.0 seemed to work. I also had to add
andriod_RANLIB=$(ANDROID_TOOLCHAIN_BIN)/$(HOST)-ranlib
to the android host for the build to complete. I was using a command like:0NO_QT=1 NO_WALLET=1 ANDROID_API_LEVEL=29 ANDROID_TOOLCHAIN_BIN=/Users/michael/Library/Android/macOS-ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin make HOST=aarch64-linux-android
icota force-pushed on Jul 10, 2019icota force-pushed on Jul 10, 2019icota commented at 12:14 pm on July 10, 2019: contributorThanks @fanquake, after adding theranlib
line I was able to build on macOS High Sierra (with Boost 1.64.0) by running:make HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_TOOLCHAIN_BIN=/Users/igor/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/ NO_QT=1 NO_WALLET=1
@greenaddress I believe Google only mandates 64-bit in addition to 32-bit. Pure 64-bit native packages are fine. Going forward I don’t personally see much demand for 32-bit since Android is moving to 64-bit so those devices are going to be increasingly rare and most likely underpowered.BlockMechanic commented at 3:36 pm on August 6, 2019: contributorThis seems to configure a build that has QT disabled, am I correct ? Also doesnt this :- #13696 resolve the QT issue?icota commented at 4:04 pm on August 6, 2019: contributor@BlockMechanic, this is built without Qt. You probably don’t want it anyway as the Qt Widgets approach Bitcoin-Qt uses is not really optimised for Android. Qt Quick OTOH would be grand as an official mobile UI but that’s a topic for another PR.BlockMechanic commented at 5:11 pm on August 6, 2019: contributor@icota thanks for the response. I’ll still try to build it with QT as is though if a project to make it mobile friendly is started, i’d be happy to helpBlockMechanic commented at 10:02 am on August 7, 2019: contributorFinally got down to it last night , only to see that the example also stipulates NO_WALLET=1 … why is this ?icota commented at 12:37 pm on August 7, 2019: contributor@BlockMechanic, there is no particular reason. It’s just an example. I haven’t tested it myself, but I guess you can build with wallet if you wish so.icota force-pushed on Sep 16, 2019icota commented at 12:39 pm on September 16, 2019: contributorRebased on top of master and added config options and a patch file enabling Android build of Qt. Thanks @BlockMechanic!in depends/README.md:38 in f2d33dee2e outdated
34 35-No other options are needed, the paths are automatically configured. 36+The paths are automatically configured and no other options are needed unless targeting Android. 37+In that case one needs to set `ANDROID_API_LEVEL` and `ANDROID_TOOLCHAIN_BIN`: 38+ 39+ make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/home/user/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin NO_QT=1 NO_WALLET=1
Sjors commented at 1:01 pm on September 16, 2019:Suggest droppingNO_QT=1
andNO_WALLET=1
; these options are explained elsewhere, and the current instructions suggest that it doesn’t work.
Sjors commented at 1:04 pm on September 16, 2019:How does one decide what API level to use? Maybe link to a page with the most recent version?
Sjors commented at 1:06 pm on September 16, 2019:Mention thatlinux-x86_64
refers to the platform that you’re doing the build on.in depends/README.md:36 in f2d33dee2e outdated
29@@ -30,8 +30,12 @@ Common `host-platform-triplets` for cross compilation are: 30 - `aarch64-linux-gnu` for Linux ARM 64 bit 31 - `riscv32-linux-gnu` for Linux RISC-V 32 bit 32 - `riscv64-linux-gnu` for Linux RISC-V 64 bit 33+- `aarch64-linux-android` for Android ARM 64 bit 34 35-No other options are needed, the paths are automatically configured. 36+The paths are automatically configured and no other options are needed unless targeting Android. 37+In that case one needs to set `ANDROID_API_LEVEL` and `ANDROID_TOOLCHAIN_BIN`:
Sjors commented at 1:01 pm on September 16, 2019:Can you add a link where one can obtain the toolchain? I’m guess here: https://developer.android.com/ndk/downloadsSjors commented at 1:42 pm on September 16, 2019: memberI tried to build f2d33de on macOS 10.14:
0$ make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/Users/sjors/dev/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin 1... 2Building zlib... 3/Users/sjors/dev/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar -o libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o 4/Users/sjors/dev/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar: no operation specified 5make[1]: *** [libz.a] Error 1 6make: *** [/Users/sjors/dev/bitcoin/depends/work/build/aarch64-linux-android/zlib/1.2.11-d7483e8fc2d/./.stamp_built] Error 2
Building depends with NO_QT=1 does work.
Building the project fails:
0./configure --prefix=/Users/sjors/dev/bitcoin/depends/aarch64-linux-android 1make 2... 3 AR leveldb/libleveldb.a 4/Users/sjors/dev/bitcoin/depends/aarch64-linux-android/share/../lib/libevent.a(evutil_rand.o): In function `evutil_secure_rng_add_bytes': 5/Users/sjors/dev/bitcoin/depends/work/build/aarch64-linux-android/libevent/2.1.8-stable-254609abc4b/evutil_rand.c:198: undefined reference to `arc4random_addrandom' 6clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Cross-compiling from macOS is generally a pain, so I don’t mind if it doesn’t work (as long as that’s documented).
I also tried cross-compiling on Ubuntu 18.04. This also failed for me:
0make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/home/dev/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/bin 1... 2Info: creating cache file /home/dev/bitcoin/depends/work/build/aarch64-linux-android/qt/5.9.8-feb0561b74d/qtbase/.qmake.cache 3ERROR: No value supplied to command line option 'android-sdk'. 4funcs.mk:251: recipe for target '/home/dev/bitcoin/depends/work/build/aarch64-linux-android/qt/5.9.8-feb0561b74d/qtbase/.stamp_configured' failed 5make: *** [/home/dev/bitcoin/depends/work/build/aarch64-linux-android/qt/5.9.8-feb0561b74d/qtbase/.stamp_configured] Error 3
Similarly it’s happy with
NO_QT=1
. I run into the samearc4random_addrandom
error when trying to buildbitcoind
though.Can you add or link to instructions on how to produce an APK? I’ll try an IBD on my Xiaomi Mi A1 (which works with ABCore). Is it possible to create an APK for
test/test_bitcoin
as well?In a followup we can figure out how to run the functional test suite on the device; that’s probably a lot more involved.
icota commented at 2:14 pm on September 16, 2019: contributorThanks for testing @Sjors. The line I’m using to build (with Qt) is:
0ANDROID_SDK=/home/user/Android/Sdk ANDROID_NDK=/home/user/Android/Sdk/ndk-bundle make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/home/user/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin
I’d be thankful if you could retry the build on both Ubuntu and Mac (mine is out of commision right now). I will make sure to update the docs with this command and your suggestions.
Sjors commented at 2:46 pm on September 16, 2019: memberI downloaded the sdk-tools from https://developer.android.com/studio#downloads, extract it to
~/dev/android-tools
. I installed Java 8 (instead of 12):0brew tap adoptopenjdk/openjdk 1brew cask install adoptopenjdk8
I used
~/dev/android-tools
to download the SDK:bin/sdkmanager "build-tools;28.0.3"
I then added the
ANDROID_SDK
andANDROID_NDK
bits:0ANDROID_SDK=/Users/sjors/dev/android-tools ANDROID_NDK=/Users/sjors/dev/android-ndk-r20 make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/Users/sjors/dev/android-ndk-r20/toolchains/llvm/prebuilt/darwin-x86_64/bin
I still get the same error with zlib. Maybe I’m pointing to the wrong places?
BlockMechanic commented at 10:07 pm on September 16, 2019: contributorTo get an actual APK there are additional files required such as AndroidManifest.xml and gradle files. Also the final APK in my case was built using androiddeployqt. I’ll work a clean PR that highlights this and has appropriate code and notesicota commented at 9:21 am on September 17, 2019: contributorI’ve updated the docs to make it clear where to get the SDK/NDK/Platform packages and whatANDROID_API_LEVEL
and other options mean. Personally, I targeted and used as an example API level 28 because that was the latest at the time.Sjors commented at 12:47 pm on September 17, 2019: memberI was missing some pieces:
bin/sdkmanager "ndk-bundle" "platform-tools" "platforms;android-28"
. So I guess I didn’t have to download this NDK seperately.It also looks like it installed the SDK at
~/dev/platforms/android-28
, not in~/Library/Android
as some articles suggest, in other words in../platforms
relative to where I extract the SDK tools. Similary I putndk-bundle
in~/dev
, not nested under the SDK.I ended up with this incantation:
0ANDROID_SDK=/Users/sjors/dev/platforms/android-28 ANDROID_NDK=/Users/sjors/dev/ndk-bundle make HOST=aarch64-linux-android ANDROID_API_LEVEL=28 ANDROID_TOOLCHAIN_BIN=/Users/sjors/dev/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin
Which results in the same zlib error. Not sure what I’m doing wrong here.
I guess I don’t need an APK to test, but could use the Android debugger directly? No idea how that works though.
icota commented at 1:06 pm on September 17, 2019: contributorI think your SDK path is wrong, YMMV but going by my (default, on Linux) setup you should setANDROID_SDK=/Users/sjors/dev
becausendk-bundle
andplatform
folders are directy under SDK root. Or look forANDROID_SDK_PATH
variable in your env.Sjors commented at 5:12 pm on September 17, 2019: memberI don’t have
ANDROID_SDK_PATH
in my env. I triedANDROID_SDK=/Users/sjors/dev
but that doesn’t make thezlib
error go away.I wonder if this is related: https://stackoverflow.com/questions/21396988/zlib-build-not-configuring-properly-with-cross-compiler-ignores-ar
I’ll try again later now that #16809 is merged.
icota commented at 8:25 am on September 19, 2019: contributorI’ve procured a Mac and I run into the exact samezlib
error. For completeness I want this to work on macOS so I will investigate.Add support for building Android dependencies 0b0cff3c61Add example Android host-platform-triplet and options c2a749c9c1Add ranlib to android.mk hosts file (fix OSX Android NDK build) 9c4cb0166eAdd config opts and patch for aarch64_android build of Qt b68f2a68c2Add full Android build example command and instructions on getting SDK/NDK 45f8219015Fix Android zlib cross compilation issue (https://stackoverflow.com/questions/21396988/zlib-build-not-configuring-properly-with-cross-compiler-ignores-ar) 80b475f159icota force-pushed on Sep 19, 2019icota commented at 9:57 am on September 19, 2019: contributorYour hunch was right @Sjors, I had to add a little fix on top of #16809. I am able to do a full Android depends build on macOS now and this is the incantation:
0ANDROID_SDK=/Users/igor/Library/Android/sdk/ ANDROID_NDK=/Users/igor/Library/Android/sdk/ndk-bundle/ make HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_TOOLCHAIN_BIN=/Users/igor/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin
Sjors commented at 11:57 am on September 19, 2019: memberI installed the version 29 SDK and ran my incantation again (
ANDROID_SDK=/Users/sjors/dev
). Depends now builds happily:0copying packages: boost openssl libevent qrencode zlib qt bdb miniupnpc zeromq 1to: /Users/sjors/dev/bitcoin/depends/aarch64-linux-android
But configure doesn’t detect QT:
0./configure --prefix=/Users/sjors/dev/bitcoin/depends/aarch64-linux-android 1... 2checking for Qt5Core Qt5Gui Qt5Network Qt5Widgets... yes 3checking for Qt5Test... yes 4checking for Qt5DBus... no 5checking for static Qt... yes 6checking for Qt5FontDatabaseSupport... yes 7checking for Qt5EventDispatcherSupport... yes 8checking for Qt5ThemeSupport... yes 9checking for Qt5DeviceDiscoverySupport... yes 10checking for Qt5AccessibilitySupport... yes 11checking for Qt5FbSupport... yes 12checking for static Qt plugins: -lqminimal... no 13configure: WARNING: Could not resolve: -lqminimal; bitcoin-qt frontend will not be built 14checking whether to build Bitcoin Core GUI... no (Qt5) 15... 16Options used to compile and link: 17 with wallet = yes 18 with gui / qt = no
See log.
Sjors commented at 12:56 pm on September 19, 2019: memberNormally QT from depends does work for me.BlockMechanic commented at 1:13 pm on September 19, 2019: contributorI installed the version 29 SDK and ran my incantation again (
ANDROID_SDK=/Users/sjors/dev
). Depends now builds happily:0copying packages: boost openssl libevent qrencode zlib qt bdb miniupnpc zeromq 1to: /Users/sjors/dev/bitcoin/depends/aarch64-linux-android
But configure doesn’t detect QT:
0./configure --prefix=/Users/sjors/dev/bitcoin/depends/aarch64-linux-android 1... 2checking for Qt5Core Qt5Gui Qt5Network Qt5Widgets... yes 3checking for Qt5Test... yes 4checking for Qt5DBus... no 5checking for static Qt... yes 6checking for Qt5FontDatabaseSupport... yes 7checking for Qt5EventDispatcherSupport... yes 8checking for Qt5ThemeSupport... yes 9checking for Qt5DeviceDiscoverySupport... yes 10checking for Qt5AccessibilitySupport... yes 11checking for Qt5FbSupport... yes 12checking for static Qt plugins: -lqminimal... no 13configure: WARNING: Could not resolve: -lqminimal; bitcoin-qt frontend will not be built 14checking whether to build Bitcoin Core GUI... no (Qt5) 15... 16Options used to compile and link: 17 with wallet = yes 18 with gui / qt = no
See log.
Hi, sorry, forgot that part see the latest addition to my PR :- #16916
see the mods in to bitcoin_qt.m4
DrahtBot commented at 3:22 pm on September 19, 2019: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #17265 (Remove OpenSSL by fanquake)
- #17008 (build: bump libevent to 2.1.11 in depends by stefanwouldgo)
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.
Sjors commented at 3:36 pm on September 19, 2019: memberI cherry-picked 2345330780e251c991a636a6a6e048fd47125a0b on top of this PR, did a
make clean
,./autogen.sh
and./configure --prefix=....
but it didn’t help:0checking for Qt5Core Qt5Gui Qt5Network Qt5Widgets... yes 1checking for Qt5Test... yes 2checking for Qt5DBus... no 3checking for static Qt... yes 4checking for Qt5FontDatabaseSupport... yes 5checking for Qt5EventDispatcherSupport... yes 6checking for Qt5ThemeSupport... yes 7checking for Qt5DeviceDiscoverySupport... yes 8checking for Qt5AccessibilitySupport... yes 9checking for Qt5FbSupport... yes 10checking for static Qt plugins: -lqminimal... no 11configure: WARNING: Could not resolve: -lqminimal; bitcoin-qt frontend will not be built 12checking whether to build Bitcoin Core GUI... no (Qt5)
Define TARGET_OS when host is android b4057d8261Update bitcoin_qt.m4
Fix to allow configure to detect at
icota commented at 1:55 pm on September 22, 2019: contributorI took a look at this and it seems @BlockMechanic’s commit neglected to set TARGET_OS but that was easy to fix. I wasn’t exactly sure if PR scope should go beyond building depends but since they have just one purpose, which is to build the main binary, I’ve now added commits to fix macOS configure and build.Patch libevent when building for Android (fix arc4random_addrandom) 24ffef0c27icota force-pushed on Sep 22, 2019fanquake commented at 2:15 am on September 23, 2019: memberTested https://github.com/bitcoin/bitcoin/pull/16110/commits/24ffef0c271739a2ca75feecb816f3218c1850bf on macOS 10.14 using macOS NDK r20, Android SDK 10 (API level 29):
0HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_SDK=/Users/michael/Library/Android/sdk/ ANDROID_NDK=/Users/michael/Library/Android/sdk/ndk-bundle/ ANDROID_TOOLCHAIN_BIN=/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin make -C depends/ -j9
0./autogen.sh && ./configure --prefix=/Users/michael/github/bitcoin/depends/aarch64-linux-android && make -j9
Looks like everything worked up until linking:
0Making all in src 1 CXXLD qt/bitcoin-qt 2/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/github/bitcoin/depends/aarch64-linux-android/share/../lib/libQt5FbSupport.a when searching for -lQt5FbSupport 3/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/github/bitcoin/depends/aarch64-linux-android/lib/libQt5FbSupport.a when searching for -lQt5FbSupport 4/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lQt5FbSupport 5/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/github/bitcoin/depends/aarch64-linux-android/share/../lib/libQt5AccessibilitySupport.a when searching for -lQt5AccessibilitySupport 6/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/github/bitcoin/depends/aarch64-linux-android/lib/libQt5AccessibilitySupport.a when searching for -lQt5AccessibilitySupport 7/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lQt5AccessibilitySupport 8<snip> 9/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/Library/Android/sdk/ndk-bundle//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so when searching for -lc++_shared 10/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/github/bitcoin/depends/aarch64-linux-android/share/../lib/libQt5Core.a when searching for -lQt5Core 11/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/github/bitcoin/depends/aarch64-linux-android/lib/libQt5Core.a when searching for -lQt5Core 12/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lQt5Core 13/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/Library/Android/sdk/ndk-bundle//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so when searching for -lc++_shared 14/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: skipping incompatible /Users/michael/Library/Android/sdk/ndk-bundle//sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so when searching for -lc++_shared 15clang++: error: linker command failed with exit code 1 (use -v to see invocation) 16make[2]: *** [qt/bitcoin-qt] Error 1 17make[1]: *** [all-recursive] Error 1 18make: *** [all-recursive] Error 1
builds: remove superfluous config_opts_aarch64_android e4c319e8a1icota commented at 2:34 pm on September 23, 2019: contributorI have a clean working tree of https://github.com/bitcoin/bitcoin/commit/e4c319e8a1c6e40a953036b942bd5d732b0bbf69,
ANDROID_SDK=/Users/igor/Library/Android/sdk/ ANDROID_NDK=/Users/igor/Library/Android/sdk/ndk-bundle/ make HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_TOOLCHAIN_BIN=/Users/igor/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin
to build depends and./configure --prefix=/Users/igor/Code/bitcoin/depends/aarch64-linux-android/
.make
works, I get all the binaries built:0... 1CXXLD libbitcoinconsensus.la 2clang++: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument] 3clang++: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument] 4Making all in doc/man 5make[1]: Nothing to be done for `all'. 6make[1]: Nothing to be done for `all-am'. 7mac:bitcoin igor$ file src/qt/bitcoin-qt 8src/qt/bitcoin-qt: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
This is on macOS 10.13.6 (17G8030). Could you do a make clean (of depends as well)?
Sjors commented at 3:01 pm on September 23, 2019: memberI used a fresh working tree as well on macOS 10.14.6, so maybe it’s a Mojave thing?MarcoFalke commented at 3:26 pm on September 23, 2019: memberWould be nice (if possible) to have one of the./ci
scripts to cross compile (similar to the macOs cross compile script)laanwj added the label Android on Sep 30, 2019laanwj added the label Feature on Sep 30, 2019Qt: patch androidjnimain.cpp to make sure JNI is initialised when statically compiled ed30684d03depends: export dynamic JNI symbols from static qtforandroid.a d419ca7e32in depends/patches/qt/fix_android_jni_static.patch:3 in d419ca7e32 outdated
0@@ -0,0 +1,18 @@ 1+--- old/qtbase/src/plugins/platforms/android/androidjnimain.cpp 2++++ new/qtbase/src/plugins/platforms/android/androidjnimain.cpp 3+@@ -890,6 +890,14 @@
fanquake commented at 3:28 pm on October 12, 2019:Can you add some more info here about what this patch is doing / link to somewhere upstream if applicable.
icota commented at 4:41 pm on October 12, 2019:When JVM loads a native lib (via system.load) it invokes its
JNI_OnLoad
function. Qt for Android uses this mechanism to do all kinds of init and register native functions for the Java side to use. The proper and supported way is to dynamically link and then each separatelibqt*.so
inits itself throughJNI_OnLoad
as it is loaded.However I wanted to link statically into one big blob so with this tiny patch I basically combined the only two Qt Base module
JNI_OnLoad
calls into one. At runtime it goes swimmingly and the GUI loads.This dependency on
JNI_OnLoad
for init and the linker confusion it causes is perhaps something that can be improved upstream. I haven’t seen it documented anywhere except in QTBUG-32618.fanquake commented at 3:29 pm on October 12, 2019: memberThis now compiles for me using:
0HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_SDK=/Users/michael/Library/Android/sdk/ ANDROID_NDK=/Users/michael/Library/Android/sdk/ndk-bundle/ ANDROID_TOOLCHAIN_BIN=/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin make -C depends/ -j9
0file src/qt/bitcoin-qt 1src/qt/bitcoin-qt: ELF 64-bit LSB pie executable ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/, with debug_info, not stripped
BlockMechanic commented at 7:47 am on October 13, 2019: contributorThis now compiles for me using:
0HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_SDK=/Users/michael/Library/Android/sdk/ ANDROID_NDK=/Users/michael/Library/Android/sdk/ndk-bundle/ ANDROID_TOOLCHAIN_BIN=/Users/michael/Library/Android/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin make -C depends/ -j9
0file src/qt/bitcoin-qt 1src/qt/bitcoin-qt: ELF 64-bit LSB pie executable ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/, with debug_info, not stripped
Can i ask why you are using ANDROID_API_LEVEL=29 ? I myself have been using 24 in the hope that using lower api levels will ensure the produced binaries/libraries/apk will be usable across more devices.
Sjors commented at 7:57 am on October 14, 2019: memberI upgraded to macOS Catalina in the mean time.
I can build depends:
0cd depends 1ANDROID_SDK=/Users/sjors/dev ANDROID_NDK=/Users/sjors/dev/ndk-bundle make HOST=aarch64-linux-android ANDROID_API_LEVEL=29 ANDROID_TOOLCHAIN_BIN=/Users/sjors/dev/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin
And then build QT:
0./configure --prefix=$PWD/depends/aarch64-linux-android 1make 2file src/qt/bitcoin-qt 3src/qt/bitcoin-qt: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
@BlockMechanic I’ll try with older SDK versions after I get the most recent version to work on a device.
greenaddress commented at 9:00 pm on October 14, 2019: contributorUnless the qt gui as currently in repo can be used on android i think this PR should limit itself to NDK support in the depends builds system without qt support. Even if the QT current GUI worked on android i would argue it wouldn’t be very useful.
I am aware of a QML PR but I imagine this PR needs to go first anyway and I’d like to think of this PR in the context of master.
Qt build support IMHO should come when there’s something usable on android as a separate PR.
Also I think support for Android needs to be for all 4 currently supported targets (i686-linux-android, x86_64-linux-android, aarch64-linux-android and arm-linux-androideabi). As a note a lot of emulators images are i686.
Android support should also be better than just android 29. I suggest android 19 as minimum for 32 bit and 21 as minimum for 64 bit (64 bit afaik was introduced at 21) or both android 21 should also be reasonable at this point (although declining, lose 6.9% of android market)
Note that the libevent patch from bitcoin_ndk but it’s actually to patch libevent code with code from a newer version of libevent - once core updates libevent it won’t be necessary.
icota commented at 6:28 am on October 15, 2019: contributorThe Qt Widgets GUI as is in master does indeed work. It’s a weird look on mobile but it does work and I’d argue it might even be useful for some people:
I’m working on a PR that I hope will make packaging as easy as
make apk
. So even though I initially intended this PR to be without Qt if it works I’d argue it should stay.Supporting all the architectures and old API levels I’m a bit more ambivalent about. I just checked on geizhals.eu and out of 3186 Android phones out there only 2 run x86, that’s 0.06% marketshare. 32-bit ARM is probably not going to run Core all that well. Android API 19 was released 6 years ago.
In my mind running Bitcoin Core is a flagship device game so that’s what I focus on. But like I said patches for supporting other arch or lower API levels are welcome. I’ll even concede that x86_64 is useful because of the emulators.
BlockMechanic commented at 8:42 am on October 15, 2019: contributor@icota Supporting all abis in this PR can be done by cherry picking from the one i built atop yours.
I have been using API level 24 specifically because starting from Android API level 24 (Android 7.0 Nougat) ifaddrs.h is supported officially, so the need to use custom implementations as was done for earlier versions is removed. In as far as i can tell API level 24 is the earliest version that can compile core as is without modifications to core’s code.
While indeed android devices vary, flagship devices from 3-4 years ago, hardware which by today’s standards is considered mid-range are perfectly capable of running it. Today’s flagship devices would not be bothered.
A mobile device user’s only issues are storage (if they do not prune) and data use, which is easily resolved by setting the app’s use to wifi only.
I fully support the inclusion of QT in the android depends builds. And on top of the previous points in favour of keeping the changes, i’d like to again point out that android is now by far the most dominant OS, and I strongly believe that our efforts to enable FULL support of it are on the right track.
icota commented at 9:14 am on October 15, 2019: contributorgreenaddress commented at 11:15 pm on October 15, 2019: contributor@icota if the gui is not pretty but otherwise ‘usable’ then linking qt makes sense - AFAIK 32bit requires some extra flags I think so I think makes sense to covered by this PR (and in CI and gitian ideally) @BlockMechanic as far as i know you don’t need to provide ifaddrs even on lower android versions - see master of https://github.com/greenaddress/bitcoin_ndk and supports android 19 as min version for 32bit and 21 for 64 bit https://github.com/greenaddress/bitcoin_ndk/blob/3023f04ea21f7f4cd0cee456f4ccf6795cc83f15/fetchbuild.sh#L41 and doesn’t provide ifaddrs (using latest ndk, r20)BlockMechanic commented at 7:25 am on October 16, 2019: contributor@greenaddress during my attempts to produce and test an apk, at first it would not compile properly, then the apk would not start , then it would crash immediately after sync. A lot of the time (using gdb) I kept getting traces to various aspects of threads and networking. Eventually after a lot of google searches and reading comments across github and stackoverflow, i used api 24 and I got a stable build without need to mod core. It is possible we could go lower, but i haven’t tried. Another part of why i am fine with 24 is that according to the distro map on https://developer.android.com/about/dashboards , it covers ~60% of known active android devices and IMO devices running lower versions of android are also likely to be underpowered and will have difficulty running core.Android: add all arch support
Add support for armv7a, i686 and x86_64 archs to android.mk Add -fPIC to depends file as anddroid requires it see https://stackoverflow.com/questions/30498776/position-independent-executables-and-android
icota force-pushed on Oct 18, 2019icota commented at 1:51 pm on October 23, 2019: contributorWith the latest changes (thanks @BlockMechanic) you can build a prefix for any of the supported Android ABIs (
armv7a-linux-android
,x86_64-linux-android
,i686-linux-android
oraarch64-linux-android
).To test the CLI binaries push to a device and run.
bitcoin-qt
however requires https://github.com/bitcoin/bitcoin/pull/17227/commits/629db6189dde6a43922632a9d39cae0c257724a6 andmake apk
. Take a look at #17227.ryanofsky commented at 3:23 pm on October 23, 2019: member@dongcarl @theuni do you want to weigh in in the build changes here and maybe concept ACK?
The changes required are surprisingly small and sensible, and currently let you build for android from both linux and macos, and we should be able to add a travis target too #16110 (comment)
laanwj requested review from theuni on Oct 26, 2019laanwj requested review from dongcarl on Oct 26, 2019laanwj added this to the milestone 0.20.0 on Oct 26, 2019cryptozeny commented at 1:19 pm on October 30, 2019: noneAWESOMEin depends/README.md:33 in f9af3ced1c
29@@ -30,8 +30,17 @@ Common `host-platform-triplets` for cross compilation are: 30 - `aarch64-linux-gnu` for Linux ARM 64 bit 31 - `riscv32-linux-gnu` for Linux RISC-V 32 bit 32 - `riscv64-linux-gnu` for Linux RISC-V 64 bit 33+- `aarch64-linux-android` for Android ARM 64 bit
Sjors commented at 3:06 pm on November 3, 2019:Don’t forget to add the new configurations you added: armv7a-linux-android, x86_64-linux-android, i686-linux-android or aarch64-linux-android
Please also mention the minimum supported version. I believe you tested down to 24?
Sjors approvedSjors commented at 5:35 pm on November 3, 2019: memberACK f9af3ce. I’m OK with merging and then improving later.
I built depends for one of the four triplets (64 bit ARM) on macOS 10.15.1 using SDK version 24 which is the minimum for now, as discussed above. We can try to support older versions in a followup PR, though generally we don’t (actively) support end-of-life distros.
Tested bitcoind on a Xiaomi Mi A1 (64 bit, Android 9). First I turned on developer mode, and enabled USB debugging. I then used ABD:
0adb devices 1add push src/bitcoind /data/local/tmp 2add push src/bitcoin-cli /data/local/tmp 3add push src/test/test_bitcoin /data/local/tmp 4adb shell 5cd /data/local/tmp 6mkdir .bitcoin 7./bitcoind -datadir=.bitcoin
Initially I got a
CANNOT LINK EXECUTABLE "./bitcoin-cli": library "libc++_shared.so" not found
error. I tried SDK version 29 instead, but that didn’t help. Usingmake LDFLAGS="-static-libstdc++"
did the trick. IDB in progress… :-)I also ran
./test_bitcoin
.Nit: in b68f2a68c211aa2264e9ca824d10a90f4a5a5af4 you add
_config_opts_aarch64_android
which you then remove in e4c319e8a1c6e40a953036b942bd5d732b0bbf69. You can use git interactive rebase toedit
that first commit anddrop
the second.Fun fact: if you have ABCore installed, it will try to mess with bitcoind via RPC :-) And if you unplug USB even a daemon will stop.
laanwj referenced this in commit 91fbcf41b3 on Nov 4, 2019laanwj merged this on Nov 4, 2019laanwj closed this on Nov 4, 2019
MarcoFalke referenced this in commit e204dc11b5 on Nov 5, 2019sidhujag referenced this in commit d03d72fdae on Nov 7, 2019immense055 commented at 9:51 am on July 26, 2020: nonefanquake locked this on Jul 26, 2020
icota luke-jr BlockMechanic greenaddress laanwj fanquake Sjors DrahtBot MarcoFalke ryanofsky cryptozeny immense055Labels
Feature Docs Build system AndroidMilestone
0.20.0
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-03 15:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me