Category Archives: Android

Building QT 6.2 for Android on Windows

First I built QT 6.2 for Windows then I installed JDK8, CMake 3.21.3 and configured QT as follows:

set "CMAKE_ROOT=E:\PFiles\cmake-3.21.3-windows-x86_64\bin"
set "NINJA_ROOT=E:\PFiles\ninja-win"
set "JDK_ROOT=C:\Program Files\Java\jdk1.8.0_301\bin"
set "MINGW_ROOT=E:\PFiles\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin"
set "PERL_ROOT=E:\PFiles\Strawberry\perl\bin"
 
set PATH=C:\WINDOWS\system32;C:\WINDOWS
set PATH=%CMAKE_ROOT%;%PATH%
set PATH=%NINJA_ROOT%;%PATH%
set PATH=%JDK_ROOT%;%PATH%
set PATH=%MINGW_ROOT%;%PATH%
set PATH=%PERL_ROOT%;%PATH%
set PATH=E:\PFiles\Python35;%PATH%
   
rem Check if the tools are in PATH
where gcc
where mingw32-make.exe
where perl.exe
where javac.exe
where python.exe
where cmake.exe
where ninja.exe

set "ANDROID_SDK_ROOT=C:\Users\D-Ef\AppData\Local\Android\Sdk"
set "ANDROID_NDK_PATH=C:\Users\D-Ef\AppData\Local\Android\Sdk\ndk\21.3.6528147"
rem See qtbase\mkspecs\android-clang\qmake.conf
set "ANDROID_NDK_PLATFORM=android-23"
rem see %ANDROID_SDK_ROOT%\build-tools folder
set "ANDROID_BUILD_TOOLS_REVISION=29.0.2"
 
set MY_INSTALL_PATH=E:\Qt\Qt6.2\android
set QT_HOST_PATH=E:\Qt\Qt6.2\windows

configure.bat -platform android-clang -prefix %MY_INSTALL_PATH% -android-sdk %ANDROID_SDK_ROOT% -android-ndk %ANDROID_NDK_PATH% -qt-host-path %QT_HOST_PATH% -android-abis x86_64 ^
  -DQT_NO_EXCEPTIONS=1 -release -force-debug-info -opensource -confirm-license
(more…)

Building QT 6.2 for Windows with MSVC2019

I cloned QT repository:

git clone --recursive https://code.qt.io/qt/qt5.git --branch v6.2.0
cd qt5

Looks like the command below is not required:

./init-repository --module-subset=all

because it prints:

Will not reinitialize already initialized repository (use -f to force)!
(more…)

QtPurchasing uses deprecated AIDL billing library

Looks like QtPurchasing uses deprecated AIDL billing library and people say that it crashes on some devices. See https://developer.android.com/google/play/billing/deprecation-faq for more information. Probably they are going to update it in 5.15.7 and move it into examples in QT 6, so it is not clear exactly what will happen with it, we probably better wait QT 5.15.7 to be released.

(more…)

Built my QT app for Android with API level 30 (Android 11)

New Android App Bundle and target API level requirements in 2021:

Starting August 2021, new apps will be required to target API level 30 (Android 11) and use the Android App Bundle publishing format. Starting November 2021, all app updates will be required to target API level 30 (Android 11). Apps with a download size of more than 150 MB are now supported by Play Asset Delivery and Play Feature Delivery.

I updated the manifest manually as follows:

<?xml version="1.0"?>
<manifest package="net.geographx.LinesGame" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.5.30" android:versionCode="161" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
(more…)

My QT Android app periodically crashes at android::RefBase::incStrong(void const*)

The call stack is:

  #00  pc 00000000000097a8  /system/lib/libutils.so (android::RefBase::incStrong(void const*) const+4)
  #00  pc 0000000000022145  /vendor/lib/libIMGegl.so
  #00  pc 000000000000ab79  /vendor/lib/libIMGegl.so (KEGLGetDrawableParameters+252)
  #00  pc 0000000000041c53  /vendor/lib/egl/libGLESv2_mtk.so
  #00  pc 000000000001663d  /vendor/lib/egl/libGLESv2_mtk.so
  #00  pc 0000000000016b01  /vendor/lib/egl/libGLESv2_mtk.so (glClear+440)
  #00  pc 000000000008acaf  /data/app/net.geographx.LinesGame-9_pUex92-tGEqE4iIbRCCw==/lib/arm/libLinesGameQt_armeabi-v7a.so (LinesGame::Squircle::beforeRendering()+270)
  #00  pc 000000000017d5b9  /data/app/net.geographx.LinesGame-9_pUex92-tGEqE4iIbRCCw==/lib/arm/libQt5Core_armeabi-v7a.so
  #00  pc 0000000000176f4d  /data/app/net.geographx.LinesGame-9_pUex92-tGEqE4iIbRCCw==/lib/arm/libQt5Quick_armeabi-v7a.so (QQuickWindowPrivate::renderSceneGraph(QSize const&, QSize const&)+172)

It is a QT bug that is not fixed yet.

Also my app crashes at the destructor of std::thread and this also a QT bug that is not fixed yet.

Building QT 6.1.0 for Android on Windows

Theoretically it can be:

git clone --recursive https://code.qt.io/qt/qt5.git --branch v6.1.0

or alternatively:

git clone https://code.qt.io/qt/qt5.git --branch v6.1.0
./init-repository --branch --module-subset=essential,qtandroidextras,qtsvg,qtquickcontrols2,qtgraphicaleffects,qtwebsockets,qtmultimedia

or

./init-repository --module-subset=all
(more…)

QT 5.15.2 app crashes on Android 5.1

My QT 5.15.2 app crashes on Android 5.1 with the following call stack:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Android/sdk_google_phone_x86_64/generic_x86_64:5.1.1/LMY48X/6402608:userdebug/test-keys'
Revision: '0'
ABI: 'x86_64'
pid: 3954, tid: 3998, name: qtMainLoopThrea  >>> net.geographx.LinesGame <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'art/runtime/mirror/art_method.cc:356] Check failed: !IsFastNative() int java.lang.Character.digitImpl!(int, int)'
    rax 0000000000000000  rbx 0000000000000f9e  rcx ffffffffffffffff  rdx 0000000000000006
    rsi 0000000000000f9e  rdi 0000000000000f72
    r8  0000000000000022  r9  0000000000000002  r10 0000000000000008  r11 0000000000000206
    r12 000000000000000b  r13 0000000000000006  r14 00007f747b51a000  r15 0000000000000051
    cs  0000000000000033  ss  000000000000002b
    rip 00007f7488099e37  rbp 00007f7467007b70  rsp 00007f74670063e8  eflags 0000000000000206
(more…)

Building QT 5.15.0 (everywhere) for Android on Windows

  • Install Android Studio with SDK and NDK API Level 28.
  • Install strawberry-perl-5.26.2.1-64bit.msi first (before mingw-w64-install.exe) to E:\PFiles
  • Install MinGW with mingw-w64-install.exe online installer. Select POSIX threads in the installer UI combobox, otherwise you will get:
  • Extract the sources from QT archive qt-everywhere-src-5.15.0.zip to E:\Qt\Qt5.15.0 and run the following script in QT root directory containing configure.bat:
(more…)

QT app is deactivated incorrectly on Android 10 in Gesture mode

If I enable Gesture mode on an Android 10 emulator by tapping System->Gestures->System Navigation->Gesture Navigation and then deactivate my app by swiping and reactivate it back, I get the following in the log:

adb logcat | grep "\ Lines"
05-04 21:52:36.389 11794 11939 D Lines   : Squircle::aboutToQuit()
05-04 21:52:36.389 11794 11939 D Lines   : InterstitialAdWrapper clear() called.
05-04 21:52:36.392 11794 11939 D Lines   : InterstitialAdWrapper InterstitialAd destructor called.
05-04 21:52:36.393 11794 11939 D Lines   : Squircle destructor called.
05-04 21:52:36.396 11794 11939 W Lines   : exit app 0
...
05-04 21:52:37.032 11794 11939 D Lines   : OslSoundPool destructor
05-04 21:52:37.117  2040  2134 W InputDispatcher: channel '8474831 net.geographx.LinesGame/net.geographx.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
05-04 21:52:37.117  2040  2134 E InputDispatcher: channel '8474831 net.geographx.LinesGame/net.geographx.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
05-04 21:52:37.123  2040  3120 I WindowManager: WIN DEATH: Window{8474831 u0 net.geographx.LinesGame/net.geographx.MainActivity}
05-04 21:52:37.123  2040  3120 W InputDispatcher: Attempted to unregister already unregistered input channel '8474831 net.geographx.LinesGame/net.geographx.MainActivity (server)'
05-04 21:52:37.136  2040  3120 W ActivityManager: Scheduling restart of crashed service net.geographx.LinesGame/org.chromium.content.app.SandboxedProcessService0 in 1000ms
05-04 21:52:37.151  2040  2057 I ActivityManager: Process net.geographx.LinesGame (pid 11794) has died: cch CRE
05-04 21:52:38.034  2040  2057 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=net.geographx.LinesGame/net.geographx.MainActivity bnds=[37,882][238,1191]} from uid 10090
05-04 21:52:38.055  2040  2057 I chatty  : uid=1000(system) Binder:2040_2 identical 8 lines
05-04 21:52:38.099  2040  2072 I ActivityManager: Start proc 12702:net.geographx.LinesGame/u0a134 for activity {net.geographx.LinesGame/net.geographx.MainActivity}
05-04 21:52:38.101 12702 12702 W raphx.LinesGam: Unexpected CPU variant for X86 using defaults: x86
05-04 21:52:38.124 12702 12702 E raphx.LinesGam: Not starting debugger since process cannot load the jdwp agent.
...
05-04 21:52:38.966  2040  2069 I ActivityTaskManager: Displayed net.geographx.LinesGame/net.geographx.MainActivity: +931ms
05-04 21:52:39.062 12702 12826 D libLinesGameQt_x86.so: Translation file has been loaded successfully:  "LinesGame_en"
05-04 21:52:39.062 12702 12826 D Lines   : App version:  "2.5.11, #133"
05-04 21:52:39.072 12702 12826 D Lines   : QT/SysInfo: Device Pixel Ratio: 3  Screen DPI:  147.131
05-04 21:52:39.106 12702 12826 D Lines   : InterstitialAdWrapper  valid
05-04 21:52:39.185 12702 12826 D Lines   : qml: Registering adfree
05-04 21:52:39.189  7632  9145 W Finsky  : [672] gcs.d(23): net.geographx.LinesGame: No account found.
05-04 21:52:39.411 12702 12826 D Lines   : qml: adfree Component.onCompleted
05-04 21:52:39.413 12702 12826 D Lines   : InterstitialAdWrapper: calling Java method ' initializeInterstitialAd ' from C++
05-04 21:52:39.413 12702 12826 D Lines   : Starting the application event loop...
05-04 21:52:39.463 12702 12826 D Lines   : onApplicationStateChanged(Qt::ApplicationActive)
(more…)

Why my QT app crashes at the destructor of std::thread on Android 10 devices?

I did some research on why my QT app crashes at the destructor of std::thread on Android 10 devices at the user side with the following call stack:

#00 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)
#01 /system/lib64/libc++.so (abort_message+232)
#02 /system/lib64/libc++.so (demangling_terminate_handler()+44)
#03 /system/lib64/libc++.so (std::__terminate(void (*)())+12)
#04 /system/lib64/libc++.so (std::terminate()+52)
#05 /system/lib64/libc++.so (std::__1::thread::~thread()+20)
#06 /apex/com.android.runtime/lib64/bionic/libc.so (__cxa_finalize+212)
#07 /apex/com.android.runtime/lib64/bionic/libc.so (exit+24)
#08 /data/app/com.domain.myapp-Rs_sm5VrLR1Jj8QW6oYByA==/lib/arm64/libplugins_platforms_qtforandroid_arm64-v8a.so

and figured out that its likely because std::thread destructor is being invoked while the thread is still joinable at some point of the application execution (thanks to G. M. on stackoverflow.com).

(more…)