Building Android CMake Projects
-
Hi
I'm working on a CMake based Android project and have some questions regarding the build process.
-
I would like to know the relation between a native build and the Android SDK (not NDK). The SDK is selected in the "Build APK" step, not in the cmake configure/build steps. So the native libraries do not depend on them, and I thought the APK was just to call the native main function, which would make a higher SDK level useless.
-
I would like to know how to build a CMake based project using the command line (e.g. for CI/CD). The CMake build step is easy, as I can just copy the Variables from QtCreator and call CMake directly. But how do I build the APK? How can I make an AAB from multiple builds? And if the SDK level is important, can I make an AAB for the same ABI but with different SDK levels?
-
-
Hi
I'm working on a CMake based Android project and have some questions regarding the build process.
-
I would like to know the relation between a native build and the Android SDK (not NDK). The SDK is selected in the "Build APK" step, not in the cmake configure/build steps. So the native libraries do not depend on them, and I thought the APK was just to call the native main function, which would make a higher SDK level useless.
-
I would like to know how to build a CMake based project using the command line (e.g. for CI/CD). The CMake build step is easy, as I can just copy the Variables from QtCreator and call CMake directly. But how do I build the APK? How can I make an AAB from multiple builds? And if the SDK level is important, can I make an AAB for the same ABI but with different SDK levels?
@Larvae said in Building Android CMake Projects:
Hi
I'm working on a CMake based Android project and have some questions regarding the build process.
- I would like to know the relation between a native build and the Android SDK (not NDK). The SDK is selected in the "Build APK" step, not in the cmake configure/build steps. So the native libraries do not depend on them, and I thought the APK was just to call the native main function, which would make a higher SDK level useless.
SDK is required to build an .apk package and to properly run the Qt wrappers (QtActivity, gradle and all the other Java code).
- I would like to know how to build a CMake based project using the command line (e.g. for CI/CD). The CMake build step is easy, as I can just copy the Variables from QtCreator and call CMake directly. But how do I build the APK? How can I make an AAB from multiple builds? And if the SDK level is important, can I make an AAB for the same ABI but with different SDK levels?
- Build with cmake.
- Run
androiddeployqt
. - Take the .apk from build dir.
Possibly, since Qt 5.14, it's enough to run
make apk
to automatically runandroiddeployqt
(as in qmake), but I don't know.If you want to bundle multiple APKs - the process is the same, you just need to set more architectures when building with cmake. You can do it by setting
ANDROID_BUILD_ABI_arm64-v8a
,ANDROID_BUILD_ABI_armeabi-v7a
,ANDROID_BUILD_ABI_x86
andANDROID_BUILD_ABI_x86_64
options in cmake. -