Android System app - "libqtforandroid.so" loading issue.
I have added a sample to AOSP package/apps to make it as a system app. After build and flash, I can see the app as system app; but it is throwing fatal error..!
From Logcat I could see, 'libqtforandroid.so' is '0' size. I verified path (/data/data/lm.ep.sysapptest/qt-reserved-files/plugins/platforms/android/) it is indeed '0' size.
I made a copy of the project with slightly different package name, and installed it on the same device, which is working fine. 'libqtforandroid.so' is present in path with 653492 bytes size.
I copied this 'libqtforandroid.so' non working app path and replaced the zero bytes file and tried to load the app. Again fatal error..! Now I could see a different error in logcat: 'dlopen("/data/data/lm.ep.sysapptest/qt-reserved-files/plugins/platforms/android/libqtforandroid.so", RTLD_LAZY) failed: dlopen failed: "/data/data/lm.ep.sysapptest/qt-reserved-files/plugins/platforms/android/libqtforandroid.so" is 32-bit instead of 64-bit'
I recompiled Android with LOCAL_MULTILIB := 32 parameter. No luck..
Request to throw some light into this issue.
My objective is to make Qt app as system app in Android.
Thanks in advance,
I missed once crucial step when adding app to AOSP: missed copying all the .so files from qt build folder to AOSP/../packages/apps/<my-app> folder and adding to .mk file.
Once this is done and build, system app is working fine.
Hi and welcome to devnet,
Glad you found out and thanks for sharing !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)
@SGaist I later realised that the issue is not fully solved.. I am marking it as unsolved. I would add the details of the issue.
Initial problem I faced in making a qt app as system app was about missing libraries.
The process I followed is:
- Made an .apk using qtCreator. (& tested the .apk as a user app in android device)
- Copied .apk to AOSP/packages/apps/my_app folder
- Created a minimum Android.mk file.
- Compiled AOSP and flashed device.
MyApp icon appeared in app drawer, but on first run it is not able to install properly, as libraries are not found.
I solved the issue by copying all the .so files from my android-build/libs folder to AOSP/packages/apps/lib folder, and making corresponding entries in Android.mk file. Now my system app is properly installed.. and running fine..
BUT I later realised a major flow. I was doing all the testing on a android eng build with SELinux disabled. The moment I did a user build, my app stopped working.. After some research, the conclusion I have arrived at is as follows:
- All the .so files are in /data/data<my_app>/qt-reserved-files/plugins folder. SELinux security policy does not allow loading libraries from /data/data.
- A copy of all these .so files are available in /system/app/<myapp>/lib/arm folder; but with long names. (i.e, plugins/platforms/libqminimal.so is available as libplugins_platforms_libqminimal.so)
- /data/system/packages.xml has entry nativeLibraryPath="/system/app/<myapp>/lib". Still qt is trying to load libraries from /data/data.
How to configure qt to load libraries from "/system/app/<myapp>/lib" folder rather than /data/data/qt-reserved-files folder ? Will the long-file-names create a problem in loading the libraries ?
Thanks in advance for the help.
You can use this patchset as a temporary solution: https://codereview.qt-project.org/194507
Al libraries from android-build/libs/<arch> must be deployed at /system/lib folder on device (or firmware before it built)