I'm setting up an Android gradle project with a few product flavors. I would like to have the <uses-permission android:name="android.permission.INTERNET" />
permission in all but one of my flavors. I know it is possible to have a particular flavor add a permission, but is it possible to have a flavor remove one?
The only other solution to this that I can think of is adding the <uses-permission android:name="android.permission.INTERNET" />
permission to all of my flavors except that one, which seems quite painful.
Product flavors are a powerful feature of the Gradle plugin from Android Studio to create customised versions of products. They form part of what we call Build Variants.
There is no direct way to get the current flavor; the call getGradle().
Build Variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Build Type applies different build and packaging settings. An example of build types are “Debug” and “Release”.
A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.
According to docs you can:
remove permission with adding to your manifest something like this <permission android:name="permissionOne" tools:node="remove"/>
and declare separate AndroidManifest.xml parts for each flavor in
src/myFlavor/AndroidManifest.xml
which will be merged this main AndroidManifest.xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With