Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved][Qt][Android]How can i add my own (librarys)*.so files into apk and use them?
When i using Qt for Android to deploy an apk, I want to use my own librarys in the application, so I copy the *.so files into the folder "android\libs\armeabi-v7a". After deployment, I did find the so files in apk,but when i use QLibrary::load to load the librarys, it failed. anybody can help?
Actually this is exactly how it works. Copy the file into that folder. Im using opencv with Qt on android and needed the native camera lib in the apk. So I copied it there and now its in the apk/libs
Maybe you didnt check "Bundle Qt Libraries in APK" (Qt 5.1.1)
So where can i find this check "Bundle Qt Libraries in APK"?
You need Qt5.1.1 for android, then go to your project's settings -> Run -> Deploy configurations -> Bundle Qt Libraries in APK
I use Qt 5.1.0 for android, it don't have that kind of check. But I don't think this is the way to solve my problem.
here is the details:
1、I use the default c++ library project created by the QtCreator as my lib;
2、I use the Qt Quick2 Application created by Creator as my mainApp;
3、I use QLibrary::Load in my mainApp to dynamic load the c++ library;
4、I copy the library to the folder "android/libs/armeabi-v7a";
5、Deploy the mainApp(now the library in the apk/libs/armeabi-v7a);
6、Install the mainApp in phone 、run it, and fail to load the library;
Maybe this can help you: http://qt-project.org/forums/viewthread/29592
Thanks moster, I will have a try
The method http://qt-project.org/forums/viewthread/29592 provided did works!
Here is my conclusion:
To add your own library into android application with Qt for Android:
1、Copy your libraries into the folder "android/libs"
2、If your application implicit dependent on the libraries, u have to modify the pro file, add " LIBS += -L"path of the lib" -llibname "
Add the following:
replace the lines:
@<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>@
@<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/any_name_you_want"/>@
The reason why we don't use bundled_libs to add our libraries is everytime we deploy the app, Qt will replace the bundled_libs in libs.xml with its own data, I don't know if this is a bug or something else.
5、Now it should be ok to load your libraries in app.