Today, in order to test the pure C Project developed using Qt Creator 3.0.0, The HelloAndroid project created in Qt 5.2 for Android development in Windows is used, add the so library generated by the pure C Project to the HelloAndroid project. The result is added, but it is not automatically copied to the generated directory and packaged into the APK.
After studying for an hour, I understood the process of generating APK by Qt Creator.
First Qt Creator will generate a json file during compilation, right under the project directory, my android-libhelloAndroid.so-deployment-settings.json. The content is as follows:
{ "description": "This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.", "qt": "C:\\Qt\\Qt5.2.0\\5.2.0\\android_armv7", "sdk": "E:/android-sdk-windows", "ndk": "E:\\Android\\android-ndk-r8d", "toolchain-prefix": "arm-linux-androideabi", "tool-prefix": "arm-linux-androideabi", "toolchain-version": "4.7", "ndk-host": "windows", "target-architecture": "armeabi-v7a", "android-extra-libs": "libhttpclient_test.so", "application-binary": "E:/qt/helloAndroid/libhelloAndroid.so"}
The application-binary in the above file is actually a so file. Here I am using libhelloAndroid. so.
It should be noted that only the so file will be generated in the compilation phase and nothing should be done. When you select the Android device, Qt Creator starts to execute a series of actions to generate an APK and push it to the device for running. The general steps are as follows:
Create the build directory and copy application-binary to copy Qt's own library and dependent library, such as libgnustl_shared.so. Copy the java file, generate AndroidManifest. xml, and resource file according to the template, call ant to compile, package, sign, and align the device, install APK and run
These actions are all completed by a program named androiddeployqt.exe. If you are interested, you can view its source code, which is included in the Qt SDK, you can also view the output information of the deployment Program in the output panel of Qt Creator. For more detailed procedures, refer to the official Qt document Deploying Applications to Android Devices, which is very detailed.
Let me talk about my problems. I added LIBS + =-lxxx to my C library in the pro file and compiled it. However, androiddeployqt did not copy libxxx. so, the dependent libxxx cannot be found during APK running. so is directly suspended. To solve this problem, you only need to add an additional dependent library. Qt Creator will pass the parameter to androiddeployqt, and the latter will be correctly packaged.
In Qt Creator, select Projects> Run> Deploy deployments> Details to view the following interface:
See the blue line and circle on the picture. Here, add the library you depend on.
Well, here we can develop Android in pure C ++ IDE. All with and without interfaces can be completed. But it seems that the service is not working yet. I haven't studied this yet.