Android Studio Cmake Build Once For All Build Variants
I have a project with C++ code (JNI) and lots of build variants and combinations. These are used to implement different brandings / flavors of the app (i.e. colors, styles, icons,
Solution 1:
By default, Android Studio IDE together with CMake and Gradle will generate a series of native build tasks named with externalNative<BuildVariant>Build
according to your build types and flavours. If you want to twist this behaviour, some workaround is as below:
- Create an Android Studio module project which only builds your native code, e.g.
shared-native
. - Let the rest of your modules dependent on this project.
For this solution, you need to consider below points:
- Put your
.so
files into a proper location that other projects can see and link with. - You can only include
debug
andrelease
build types for thisshared-native
module project to avoid too many times of re-build. Or you can simply to let your other projects depends on the release type so that it will be built only ONCE.
Post a Comment for "Android Studio Cmake Build Once For All Build Variants"