Tl;dr: Adding a new product flavor makes the sync run forever.
I have a multi-module Android project set with four flavors & two flavor dimensions. The flavors are declared both in the app build.gradle and in each feature build.gradle. In case it’s relevant, for features it’s all declared in a dedicated file and applied to the feature using the following:
apply from: "$rootDir/flavor_config.gradle".
When adding a new flavor, regardless of it being in a new dimension or not, when hitting ‘sync’ it eventually gets stuck on “Gradle: Build model…”. I let it run once for 3 hours just to make sure and it was still running. When I removed the added flavor, everything was working fine again.
When adding those just to app module, the build succeeds for one flavor and reasonably fails for two. Adding them to the feature modules is the change that's triggering the issue.
My question is: What can cause this kind of behavior? Even if there is some missing configuration or anything, I’d expect it to reach a timeout rather than running for hours, yet nothing showed up.
I tried the “regular” things to no avail:
- Invalidate cache & restart
- PC restart
- Manually deleting Gradle cache
- Playing around with the flavors config, including variant filters
I also tried searching the web for a few days and investigated the Android Studio logs but couldn’t come up with anything useful.
Thanks a lot for your help, it’s much appreciated.