9

When I changed the variants in my project with android studio 3.5 in 2019, I could not change from Active Build Variants. I solved this by deleting the .idea and Build folders of the project and changing the Varieties from Active Build Variants in a new way.

**2019 :

Project build Gradle: 3.5.3

Android Studio: 3.5**

I can't change the Variants from Active Build Variants in any way in the project by keeping the same Build Gradle the same product Flavors Configuration. This is the only difference between the previous configuration and the current one

**2020 :

Project build Gradle: 3.5.3

Android Studio: 4.0.1**

Has anyone worked with Recent Build Variants? What could be the approximate cause of this kind of problem?

build varients

Product Flavour

4 Answers4

24

Try to untick File > Settings > Experimental > Gradle > Only sync the active variant

gevge
  • 399
  • 2
  • 6
3

Maybe your project folder is in a symbol linked location, try to use the real location.

der banfee
  • 31
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 03 '22 at 11:35
  • 1
    This was the issue in my case. I have my project stored in iCloud Drive and had created a symlink to shorten the path. Opening the project via the symlink path broke variant switching, whereas opening at the original path worked fine. – bmat Jul 14 '23 at 20:49
3

I fixed this by resyncing the gradle. enter double shift --> then search for sync --> resync gradle with project files.

mmdreza baqalpour
  • 1,106
  • 9
  • 18
0

In my case I had to update the buildToolVersion as it was lower than needed with the AGP version in one of my modules. When I updated it, I could change the build variant without any problem.

starball
  • 20,030
  • 7
  • 43
  • 238