Android: fix GUI not loading on Qt 5.15 #504

pull icota wants to merge 2 commits into bitcoin-core:master from icota:master changing 6 files +25 −7
  1. icota commented at 7:53 AM on December 12, 2021: contributor

    Qt 5.14 introduced certain breaking changes to the way it parses AndroidManifest.xml metadata.

    This PR also adds an explicit QAndroidPlatformIntegrationPlugin import to bitcoin.cpp (in line with other platforms). I'm not sure why Android GUI worked without this before but it certainly doesn't on Qt 5.15.

    We could do without Q_IMPORT_PLUGIN before because we were manually pulling a JNI_Onload function to the linkage.

  2. icota commented at 8:12 AM on December 12, 2021: contributor
  3. hebasto commented at 9:47 AM on December 12, 2021: member

    Concept ACK.

  4. hebasto commented at 9:50 AM on December 12, 2021: member

    https://cirrus-ci.com/task/5550307582148608:

    ld: error: duplicate symbol: JNI_OnLoad
    >>> defined at qjnionload.cpp
    >>>            qjnionload.o:(JNI_OnLoad) in archive /tmp/cirrus-ci-build/depends/aarch64-linux-android/lib/libQt5Core_arm64-v8a.a
    >>> defined at androidjnimain.cpp
    >>>            androidjnimain.o:(.text.JNI_OnLoad+0x0) in archive /tmp/cirrus-ci-build/depends/aarch64-linux-android/plugins/platforms/libplugins_platforms_qtforandroid_arm64-v8a.a
    clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
    make[2]: *** [Makefile:6462: qt/test/test_bitcoin-qt] Error 1
    
  5. hebasto commented at 10:28 AM on December 12, 2021: member

    Tested f2f924e919b110cc5f33aac4caa4b296991d3706 (configured with --disable-tests):

    Screenshot_1639304796

  6. icota commented at 10:56 AM on December 12, 2021: contributor

    I've updated the PR description to explain why we could get away with not using Q_IMPORT_PLUGIN.

    Broken qt_test linkage in CI is related. I'm trying to figure out a nice way to fix this.

  7. hebasto commented at 11:27 AM on December 12, 2021: member

    I've updated the PR description to explain why we could get away with not using Q_IMPORT_PLUGIN.

    Broken qt_test linkage in CI is related. I'm trying to figure out a nice way to fix this.

    The following patch fixes link error:

    --- a/build-aux/m4/bitcoin_qt.m4
    +++ b/build-aux/m4/bitcoin_qt.m4
    @@ -162,6 +162,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
           AC_DEFINE([QT_QPA_PLATFORM_COCOA], [1], [Define this symbol if the qt platform is cocoa])
         elif test "$TARGET_OS" = "android"; then
           QT_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lplugins_platforms_qtforandroid_$ANDROID_ARCH -ljnigraphics -landroid -lqtfreetype_$ANDROID_ARCH $QT_LIBS"
    +      QT_TEST_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lplugins_platforms_qtforandroid_$ANDROID_ARCH -ljnigraphics -landroid -lqtfreetype_$ANDROID_ARCH $QT_TEST_LIBS"
           AC_DEFINE([QT_QPA_PLATFORM_ANDROID], [1], [Define this symbol if the qt platform is android])
         fi
       fi
    

    Not sure if it is optimal though.

    UPDATE: See a more preferable patch in #504 (comment).

  8. in src/qt/bitcoin.cpp:69 in f2f924e919 outdated
      64 | @@ -65,6 +65,8 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin);
      65 |  #elif defined(QT_QPA_PLATFORM_COCOA)
      66 |  Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
      67 |  Q_IMPORT_PLUGIN(QMacStylePlugin);
      68 | +#elif defined(QT_QPA_PLATFORM_ANDROID)
      69 | +Q_IMPORT_PLUGIN(QAndroidPlatformIntegrationPlugin);
    


    hebasto commented at 11:28 AM on December 12, 2021:

    The same in qt/test/test_main.cpp?

  9. hebasto commented at 11:36 AM on December 12, 2021: member

    I've updated the PR description to explain why we could get away with not using Q_IMPORT_PLUGIN. Broken qt_test linkage in CI is related. I'm trying to figure out a nice way to fix this.

    The following patch fixes link error:

    --- a/build-aux/m4/bitcoin_qt.m4
    +++ b/build-aux/m4/bitcoin_qt.m4
    @@ -162,6 +162,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
           AC_DEFINE([QT_QPA_PLATFORM_COCOA], [1], [Define this symbol if the qt platform is cocoa])
         elif test "$TARGET_OS" = "android"; then
           QT_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lplugins_platforms_qtforandroid_$ANDROID_ARCH -ljnigraphics -landroid -lqtfreetype_$ANDROID_ARCH $QT_LIBS"
    +      QT_TEST_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lplugins_platforms_qtforandroid_$ANDROID_ARCH -ljnigraphics -landroid -lqtfreetype_$ANDROID_ARCH $QT_TEST_LIBS"
           AC_DEFINE([QT_QPA_PLATFORM_ANDROID], [1], [Define this symbol if the qt platform is android])
         fi
       fi
    

    Not sure if it is optimal though.

    A more optimal suggestion:

    --- a/src/Makefile.qttest.include
    +++ b/src/Makefile.qttest.include
    @@ -52,7 +52,7 @@ if ENABLE_ZMQ
     qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
     endif
     qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
    -  $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
    +  $(LIBLEVELDB_SSE42) $(LIBMEMENV) $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \
       $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBSECP256K1) \
       $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(SQLITE_LIBS)
     qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS)
    

    UPDATE: Suggesting to move this PR into the main repo as it touches the code outside the src/qt.

  10. in src/qt/android/.gitignore:7 in f2f924e919 outdated
       2 | @@ -3,7 +3,5 @@
       3 |  /gradle/wrapper
       4 |  /gradlew*
       5 |  /libs
       6 | -/res/layout
       7 | -/res/values*
    


    hebasto commented at 2:58 PM on December 12, 2021:

    While here, maybe s|/gradle/wrapper|/gradle| as /gradle/wrapper is the only subdirectory in /gradle, no?

  11. icota commented at 8:57 AM on December 13, 2021: contributor

    UPDATE: Suggesting to move this PR into the main repo as it touches the code outside the src/qt.

    Is there a nice way to do this? I'd like to preserve comments and stuff.

  12. hebasto commented at 9:24 AM on December 13, 2021: member

    @icota

    UPDATE: Suggesting to move this PR into the main repo as it touches the code outside the src/qt.

    Is there a nice way to do this?

    No, there is not, unfortunately.

    I'd like to preserve comments and stuff.

    A link to this PR in the OP will work fine.

  13. build, qt: use static QAndroidPlatformIntegrationPlugin 026089d671
  14. build, android: Fix Android GUI not loading on Qt 5.15
    Qt 5.14 introduced certain breaking changes to the way it parses
    AndroidManifest.xml metadata
    
    https://lists.qt-project.org/pipermail/interest/2020-January/034372.html
    800ff978bc
  15. icota force-pushed on Dec 13, 2021
  16. icota commented at 9:40 AM on December 13, 2021: contributor
  17. icota closed this on Dec 13, 2021

  18. fanquake referenced this in commit 965ffe2bed on Dec 15, 2021
  19. bitcoin-core locked this on Dec 13, 2022
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-27 05:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me