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…)Category Archives: Platforms and frameworks
Invokable constructor in QT
In QT 5.15 I declare a class with an invokable constructor:
class TestClass : public QObject
{
Q_OBJECT
public:
Q_INVOKABLE TestClass(QString val) {}
};
Q_DECLARE_METATYPE(TestClass*)
register its type:
qRegisterMetaType<TestClass*>();
‘Invalid UTF-8 code encountered.’ close reason with QWebSocket
I get close reason: ‘Invalid UTF-8 code encountered.’ (code=1007) with QWebSocket in the following scenario:
- I connect to
Binancestreamwss://stream.binance.com:9443/streamwithQWebSocket::open. - Successfully receive messages for some time period (a few hours).
Binancedisconnects me when its servers load increases (because I have low-priority API) and I get close reason code=1000 that indicates a normal closure.- Try to reconnect multiple times by calling
QWebSocket::openagain, butBinancecloses the connection with close reason ‘Invalid UTF-8 code encountered.’ (code=1007) that indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message). - Restart the application manually and connect successfully.
The difficulty of reproducing the bug is that Binance disconnects me rarely (once a day, for example) and experimentation with disconnecting the network cable from my machine does not have this effect, after I connect the cable back, QWebSocker reconnects successfully. When I disconnect the network cable I get Error: ‘Unknown error’ (code=-1), Close reason: ” (code=1000).
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"/>
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.
Applying a path that fixes a bug in QT 5.15.2
There was a bug in QT 5.15.2 that results in app crash on Android 5.1 and a patch:
Submodule qtbase contains modified content
diff --git a/qtbase/src/corelib/plugin/qlibrary_unix.cpp b/qtbase/src/corelib/plugin/qlibrary_unix.cpp
index a5c72f81d9..5cd21b67a4 100644
--- a/qtbase/src/corelib/plugin/qlibrary_unix.cpp
+++ b/qtbase/src/corelib/plugin/qlibrary_unix.cpp
@@ -243,10 +243,10 @@ bool QLibraryPrivate::load_sys()
}
if (hnd) {
using JniOnLoadPtr = jint (*)(JavaVM *vm, void *reserved);
- JniOnLoadPtr jniOnLoad = reinterpret_cast<JniOnLoadPtr>(dlsym(pHnd, "JNI_OnLoad"));
+ JniOnLoadPtr jniOnLoad = reinterpret_cast<JniOnLoadPtr>(dlsym(hnd, "JNI_OnLoad"));
if (jniOnLoad && jniOnLoad(QtAndroidPrivate::javaVM(), nullptr) == JNI_ERR) {
dlclose(hnd);
- pHnd = nullptr;
+ hnd = nullptr;
}
}
#endif
Looks like it was simply a typo and pHnd was replaced with hnd.
QT 5.15.3 where the bug was fixed is commercial so I applied the patch by myself (thanks to danilabagroff from stackoverflow.com):
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
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
Dragging a link from a browser to a QML app
When a link is dragged from a browser on Window 10 platform it contains the page title, but they did not make it accessible in QML:
import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Scroll")
id: root
DropArea {
id: dropArea;
anchors.fill: parent
onEntered: {
root.color = "gray";
drag.accept (Qt.LinkAction);
}
Publishing QT application in Apple App Store
I succeeded with building my app for iOS and my first step in publishing the app in App Store was opening generated .xcodeproj file in XCode, but XCode froze displaying rotating progress indicator and wait cursor.

