Building multiple Android apps from the same proj.android directory?

I normally develop on iOS and Xcode. In Xcode, I can have multiple targets. This means I can build multiple apps all from the same code base. I have 15 versions of a game that share a lot of code.

I am trying to bring this to Android.

How do I create multiple targets when doing Android development from the command-line?

I also use common classes, but in 1 project directory i dont mix them. They are separated projects maybe with different settings… So why?
Or why not simple call each build from a script?

https://developer.android.com/studio/build/build-variants.html#workBuildVariants

have a look on this gradle setup

2 Likes

The answer of @energyy is correct. This can bei done bei productFlavors in the gradle file. But with this change, the cocos command line tool can’t copy the apk into the bin folder. This is the only limitation.

Maybe sometime the command line tool will analyse the build.gradle file and copy all APKs into the bin folder. If someone change this, please be aware, that you can also split the APK by abi (armeabi, x86, …). So you can end up in productFlavors times abi. My current project has 3 flavors and uses 4 abis, so I get 12 APKs with just one call -> cocos compile -p android --android-studio --app-abi "armeabi armeabi-v7a arm64-v8a x86"

Thanks, this is great. However, I am still stuck compiling my project. Any thoughts here? Trouble compiling on Android