QT 5.12.4 armv7 application not working if arm64 libs are present
-
In preparation for google play 64 bit requirement I updated my project to include
arm64-v8a
libs.
So now I have botharmeabi-v7a
andarm64-v8a
folders insideAndroid/jni/
folder.I use
Clang Qt 5.12.4 for Android ARMv7
andClang Qt 5.12.4 for Android ARM64-v8a
kits for it's respective builds.The issue now is that only the 64 bit version works. Even when I use
armeabi-v7a
for building, it ends up with the following errors trying to look for arm64:W System : ClassLoader referenced unknown path: I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libc++_shared.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5Core.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5AndroidExtras.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5Gui.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5Network.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5Multimedia.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5Qml.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5Quick.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5QuickTemplates2.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5QuickControls2.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5WebSockets.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5MultimediaQuick.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5QuickParticles.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5MultimediaQuick.so' I Qt JAVA : Can't find '/data/app/com.myproject.test-VAF1p6T7dJCG1T41Wzsu-g==/lib/arm64/libQt5RemoteObjects.so' E AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread E AndroidRuntime: Process: com.myproject.test, PID: 1406 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: file offset for the library "/data/data/com.myproject.test/qt-reserved-files/plugins/platforms/android/libqtforandroid.so" >= file size: 0 >= 0 E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:928) E AndroidRuntime: at java.lang.System.load(System.java:1633) E AndroidRuntime: at org.qtproject.qt5.android.QtNative$2.run(QtNative.java:183) E AndroidRuntime: at org.qtproject.qt5.android.QtThread$2.run(QtThread.java:87) E AndroidRuntime: at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61) E AndroidRuntime: at java.lang.Thread.run(Thread.java:764) E MQSEventManagerDelegate: failed to get MQSService.
All android files are handled by gradle, now I'm not well-versed with gradle, but I assume it should handle which abi to use based on the kit used to build?
If I remove
arm64-v8a
from the filter the 32-bit app will work, but then the 64-bit one doesn't.
build.gradle:android { ... defaultConfig { minSdkVersion 19 ndk { abiFilters "armeabi-v7a", "arm64-v8a" } } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java'] aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl'] res.srcDirs = [qt5AndroidDir + '/res', 'res'] resources.srcDirs = ['src'] renderscript.srcDirs = ['src'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs', 'jni'] } } ... }
Has anyone encountered a similar issue or has any idea how to make it build only the libs for the kit I'm using?
I don't really understand why it's looking for 64-bit libs when building withClang Qt 5.12.4 for Android ARMv7
.SDK Version: 26.1.1
NDK Version: 19.2.5345600
JDK version: jdk1.8.0_212 -
hi @Wiru
as of right now Qt(Creator) does not support aab you have to build both APKs completely separately and manage them on in the play consolefor more information see here
-
@J-Hilk I'm not trying to make an aab, I would just want to build the apk depending on the kit I use.
If I build withClang Qt 5.12.4 for Android ARMv7
I want it to be only 32 bit, and forClang Qt 5.12.4 for Android ARM64-v8a
only 64 bit; I did some research regarding the aab support in Qt so I know it's not supported (I did read the linked bug report before, tho not in much detail asaab
is not what I'm targeting at the moment), or do you mean it's an issue when botharmeabi-v7a
andarm64-v8a
libs are present in a project? -
@Wiru
if you setup your project correctly, than you should have different gradle folders/files for each Qt version -> referencing both armeabi-v7a. and arm64-v8a is, imho wrong.did you manipulate the build.gradle file yourself, or is it the auto generated one?
-
@J.Hilk
It's a modified version of the auto generated one from before when only 32-bit was available, more or less I just added thefilter
andjniLibs.srcDirs = ['libs', 'jni']
.I still don't quite understand why it's an issue to have both
armeabi-v7a
andarm64-v8a
present in the same project, as soon as I added the arm64 the 32 bit app isn't working. A better question might be why is theClang Qt 5.12.4 for Android ARMv7
even trying to look for 64 bit libs?In any case, is it possible to have 2 build.gradles in the same project and just use the right one for the build kit used? I'll also try to look more into this, thank you for the quick response.
-
@Wiru said in QT 5.12.4 armv7 application not working if arm64 libs are present:
In any case, is it possible to have 2 build.gradles in the same project and just use the right one for the build kit used?
sure, if you wrap it accordingly, inside your pro file. it should work
contains(ANDROID_TARGET_ARCH,armeabi-v7a) { ANDROID_PACKAGE_SOURCE_DIR = \ $$PWD/android/v7 }
-
@J.Hilk
Is it enough to only have build.gradle inside$$PWD/android/v7
$$PWD/android/v8
?
I'm having trouble adjusting it correctly, since thebuild.gradle
is now in a subfolder, all sources should start with../
to look for them in the parent folder? If I do that it results in a empty app loading.Guess I'm doing something wrong could you please help with updating the paths as I'm not sure how it should look now.
This is how it looked before:android { ... defaultConfig { minSdkVersion 19 ndk { abiFilters "armeabi-v7a", "arm64-v8a" } } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java'] aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl'] res.srcDirs = [qt5AndroidDir + '/res', 'res'] resources.srcDirs = ['src'] renderscript.srcDirs = ['src'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs', 'jni'] } } ... }
I tried adding
../
to all paths, but with or without it, it just makes an empty applicationEDIT:
Normal reasoning would say to have all android files inside the respectiveANDROID_PACKAGE_SOURCE_DIR
, but that would result in duplicating files that don't depend on abi, (assets, res, etc.), so I hope that's not the case and onlybuild.gradle
can be in a subfolder?EDIT 2:
Managed to make a workaround for now, figured I could use the build path to check which abi is used and filter accordingly. It's silly, but it works.defaultConfig { minSdkVersion 19 ndk { if(qt5AndroidDir.contains("android_armv7")) { abiFilters "armeabi-v7a" } if(qt5AndroidDir.contains("android_arm64_v8a")) { abiFilters "arm64-v8a" } } }
-
@Wiru said in QT 5.12.4 armv7 application not working if arm64 libs are present:
Normal reasoning would say to have all android files inside the respective ANDROID_PACKAGE_SOURCE_DIR, but that would result in duplicating files that don't depend on abi, (assets, res, etc.), so I hope that's not the case and only build.gradle can be in a subfolder?
that's how I do it. It's fine, I only have few native classes in my code but your solution may be better.
Where do you make that check exactly ?
-
@J.Hilk
It's inbuild.gradle
; theabiFilters
go underandroid { defaultConfig { ndk{ abiFilters ... ...
Works great with manual builds and default settings (since
qt5AndroidDir
is named based on the kit used) , for automated it might be a bit tricky if custom folder names are used, but as long as it contains the checked strings it should work. -
@climax You do not need separate
ANDROID_PACKAGE_SOURCE_DIR
s for each architecture unless you are doing something custom on the java side. The error here was in usingabiFilters
in the gradle file. Remove that and it works fine. You can verify by picking any android example in Qt Creator and building for both architectures.