Build All productFlavors Automatically in same time - android

I have more than 10 different productFlavors and whenever I change my project I have to change select build variant and then build apk for each of them.
Is there any way that build all productFlavors at the same time?

You can use gradle for it - first clean, and then assembleRelease Both you can find on right side: Gradle -> app -> Tasks -> build and then first clean, and after this assembleRelease (that should build all products flavours)
If you want to make Debug builds, then you can use assembleDebug

Related

Android Gradle - Filter out variant(s) only for a specific task

I'm using Android Studio 4.2.0 and Gradle 6.7.1.
I work on an Android library project that when gets built on the release CI it builds every single variant even if I really need one specific variant.
I already have a variantFilter in place that excludes release builds that are not from the production flavor, like this:
android {
variantFilter { variant ->
def names = variant.flavors*.name
if (variant.buildType.name == 'release' && !names.contains("production")) {
setIgnore(true)
}
}
}
Now, when the install task run, I'd like to only build the productionRelease variant.
Is it possible to filter out variants based on the Gradle task that it's been launched?
Or is it possible to filter the Gradle task graph to keep only the install task from the productionRelease variant?
I've tried many configuration but failed, but I know that this community will be able to provide valuable suggestions!
Is it possible to filter out variants based on the Gradle task that it's been launched?
Yes, for your case, there is a way to assemble and install the specific variant. You can try with this command :
./gradlew clean installProductionRelease --stacktrace --debug --info

re-sync Gradle using Command line

Im building script that will change some info in gradle flavors dynamic and then build apk Using gradlew assemble' + $UsableProjectName + 'Release
Now my problem is the new flavor i have added is not seen by gradle yet or in the project index files, so i need to click on gradle sync to be able to recognise it and run successful build.
I have tried :
gradlew --recompile-scripts
and
gradlew assemble
But after running both of them i still cant see the new flavor until i do manual sync from the android studio.
Is there away to sync the gradle using command line ?
It shall work without doing gradle sync.
do run command 'gradlew tasks' to see list of 'Build Tasks'; new flavor shall be listed as 'assembleflavor1' or 'assembleflavor2'.

Android aar publish to Artifacotry through TeamCity

Currently we are using TeamCity for continuous integration and I have configured my Android library to build with TeamCity. I can upload my aar to Artifactory manualy by executing gradle assembleRelease artifactoryPublish command.
Is it possible to publish my library aar file to Artifactory repository from the TeamCity?
Assuming you already have builds running on TeamCity:
On TeamCity go to your Project Settings then Build Configurations, Select the build configuration that runs when ever TeamCity runs.
Inside that Build Configuration select Build Step: Gradle, then click the Add Build Step Button.
Select Gradle from the drop down menu.
Give it sensible name e.g. "Publish artifact"
Add your task names in:
Click Save
Then run your TeamCity build like you usually would.
TeamCity runs Gradle tasks. Just use the assembleRelease artifactoryPublish tasks in TeamCity.

Gradle assemble specific flavor and build

Running ./gradlew tasks shows options to assemble all builds for a particular flavor, or all flavors for a particular build. Does there exist an option to assemble for a specific flavor and build combination?
Yes - you're referring to a specific build variant
./gradlew assembleFlavoraBuildb
Where your flavor is called flavora and your build is buildb
Read more here:
http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Building-and-Tasks

Android build variants on travis.ci

I currently have an Android project using gradle and integrated with travis.ci which has different productFlavors and buildTypes. When the "connectedCheck" task is then executed on travis.ci, it tries to package all build variants (all combinations of flavors and types). Some of them fail as the release builds need password input which I can't automate at the moment. Is there a way to tell travis.ci to build and test only a certain build variant of an Android project?
Say you only want to run the product flavor Trial and the build type Debug.
Instead of running ./gradlew assemble connectedCheck, which is similar to what you're doing, run this instead:
./gradlew assembleTrialDebug connectedCheckTrialDebug
So here's how I made it work:
Run a connectedAndroidTest<productFlavor><buildType> task instead of connectedCheck.
Also set the assemble task in the install section of the .travis.yml:
install: - TERM=dumb ./gradlew -s assemble<productFlavor><buildType>

Categories

Resources