Problem with QMagnetometer et QAccelerometer under Qt 5.14.1 and Android
Unsolved
Mobile and Embedded
-
Since the upgrade to Qt 5.14.1, my application doesn't seem to find the accelerometer and the magnetometer under Android anymore.
The following code :
compass = new QMagnetometer(this); // start the sensor if (compass) { bool result = compass->start(); qDebug() << "result compass->start : " << result; if (compass->isActive()) { MessageLog("Magnetometer sensor activated"); } else { MessageLog("Magnetometer sensor not available!"); compass->stop(); } } accel = new QAccelerometer(this); // start the sensor if (accel) { bool result = accel->start(); qDebug() << "result accel->start : " << result; if (accel->isActive()) { MessageLog("Accelerometer sensor activated"); } else { MessageLog("Accelerometer sensor not available!"); accel->stop(); } }
gives result compass->start : false and result accel->start : false
Everything worked fine with Qt 5.13.2.
In the AndroidManifest.xml file, I added the lines :
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" /> <uses-feature android:name="android.hardware.sensor.compass" android:required="true" />
the pro file contains :
CONFIG += mobility MOBILITY = QT += androidextras #CONFIG += console # Android armeabi-v7a equals(ANDROID_ABIS, armeabi-v7a) { message("armeabi-v7a") QMAKE_CXXFLAGS_DEBUG += "-fsigned-char -g -O0" QMAKE_CFLAGS_DEBUG += "-fsigned-char -g -O0" QMAKE_LFLAGS_DEBUG += "-O0 -Wl,--allow-multiple-definition" QMAKE_CXXFLAGS_RELEASE += "-fsigned-char -O3 -fopenmp -DNDEBUG" QMAKE_CFLAGS_RELEASE += "-fsigned-char -O3 -fopenmp -DNDEBUG" QMAKE_LFLAGS_RELEASE += "-O1 -Wl,--allow-multiple-definition" LIBS += -fopenmp ANDROID_EXTRA_LIBS = \ $$PWD/android/lib/armv7/1.1/libcrypto.so \ $$PWD/android/lib/armv7/1.1/libssl.so ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android DEFINES += \ QTAT_APK_INFO \ QTAT_APK_EXPANSION_FILES include(QtAndroidTools/QtAndroidTools.pri) #ANDROID_PERMISSIONS= INCLUDEPATH += QtAndroidTools INCLUDEPATH += ../librairies/quazip-0.8.1/quazip LIBS += "../librairies/freetype-2.10.1/android/armv7/libfreetype.a" LIBS += "../librairies/assimp-5.0.0/android/armv7/libassimp.a" LIBS += "../librairies/quazip-0.8.1/android/armv7/libquazip5.a" LIBS += "C:\Users\KarlHal\AppData\Local\Android\Sdk\ndk\20.1.5948944\sources\cxx-stl\llvm-libc++\libs\armeabi-v7a\libc++_static.a" }
There are no special warnings about QSensors. I have this strange warning, though:
Error reading file: C:/Qt/5.14.1/android/plugins/se_armeabi-v7a.sors/libplugins_se_armeabi-v7a.sors_qtse_armeabi-v7a.sors_android_armeabi-v7a.so: No such file or directory
What could go wrong?
Thanx!