Removing AndroidManifest element with gradle product flavors

前端 未结 3 1982
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 10:01

I\'m setting up an Android gradle project with a few product flavors. I would like to have the

相关标签:
3条回答
  • 2021-01-04 10:38

    I know this is old but now there is a new attribute called tools:node="remove" that enables you to remove a tag from the Manifest.

    Declare the header of your manifest as follows:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools">
    

    Also you have to add your tag like this:

    <uses-permission android:name="android.permission.INTERNET" tools:node="remove" />
    

    I hope this helps others.

    Source: HERE

    Also Android documentation: HERE

    EDIT:

    Edited the answer to match new API changes. Thanks to Martin L. for his comment

    0 讨论(0)
  • 2021-01-04 10:40

    According to docs you can:

    1. remove permission with adding to your manifest something like this <permission android:name="permissionOne" tools:node="remove"/>

    2. and declare separate AndroidManifest.xml parts for each flavor in src/myFlavor/AndroidManifest.xml which will be merged this main AndroidManifest.xml

    0 讨论(0)
  • 2021-01-04 10:53

    gradle merges manifests so probably not. I have solved similar problem (broadcast receivers package names) by removing tag from main manifest and adding it to all specific flavors.

    0 讨论(0)
提交回复
热议问题