Android Studio未显示全部Build Variants(缺失plusDebug/plusRelease)求排查方向
plusDebug and plusRelease Build Variants Hey there, let's figure out why your plusDebug and plusRelease build variants aren't showing up in Android Studio. I've run into similar hiccups before, so here are the key areas to check step by step:
Verify your
productFlavorsconfiguration
Double-check your module-levelbuild.gradlefile to ensure theplusflavor is properly defined with no syntax mistakes. Even a missing brace or extra comma can break variant generation. Compare it directly to your working project's setup—make sure it looks something like this:productFlavors { free { // Your free flavor config (e.g., applicationIdSuffix ".free") } plus { // Your plus flavor config (even an empty block is valid, but the block must exist) } }Also watch out for typos or case sensitivity—Gradle treats
Plusandplusas entirely separate flavors.Check for variant filtering or dimension mismatches
- Look for a
variantFilterblock in yourandroidclosure—this could be explicitly hidingplusvariants. For example, this code would wipe out all plus-related builds:android { variantFilter { variant -> if (variant.flavors*.name.contains("plus")) { setIgnore(true) } } } - If you're using flavor dimensions, ensure all flavors are assigned to the same dimension. Mismatched dimensions can prevent variant combinations from being generated:
flavorDimensions "versionType" productFlavors { free { dimension "versionType" } plus { dimension "versionType" } }
- Look for a
Fix Gradle sync and cache issues
- First, click the Sync Project with Gradle Files button (the elephant icon) in Android Studio's toolbar—sometimes a partial sync fails to register new flavors.
- If that doesn't work, invalidate caches and restart: go to
File > Invalidate Caches... > Invalidate and Restart. This clears Android Studio's cached variant data, which often gets stuck. - You can also manually delete the project's
.gradlefolder and your module'sbuildfolder, then re-sync to force a fresh build configuration.
Confirm you're looking at the right module
If your project has multiple modules, it's easy to accidentally check the Build Variants window for a module that doesn't include theplusflavor. Make sure the dropdown at the top of the Build Variants panel is set to the correct module with your flavor setup.Check Gradle Console for hidden errors
Open the Gradle Console (bottom panel in Android Studio) while syncing your project. Sometimes Gradle will skip variant generation silently due to configuration errors (like invalid manifest entries, missing resources, or conflicting dependencies) and only log warnings/errors here. Fixing these underlying issues will bring back your missing variants.
内容的提问来源于stack exchange,提问作者RufusInZen

