androidandroid-studiogoogle-advertising-id

In an Android project, can you use permissions only for select (as opposed to all) flavors?


My client just got an e-mail from Google Play, saying that once his app starts targeting Android 13 (which hasn't happened yet), we need to use the AD_ID permission. And it's an easy one-line addition to AndroidManifest.xml. Problem is, the app has several configurations and one one uses ads and hence needs AD_ID. Is there a simple way to use permissions only for some flavors (like free but not premium)?


Solution

  • You can have an AndroidManifest.xml file in a source set for your free flavor (e.g., app/src/free/AndroidManifest.xml for an app module). In there, have your <uses-permission> element in the proper spot as a child of <manifest>, but otherwise leave it empty. That will get merged in with your main manifest for free builds and will not be included in your premium builds.