# Edit AndroidManifest attributes

**URL:** <https://forums.fusetools.com/t/edit-androidmanifest-attributes/6677>\
**Category:** How-to Discussions\
**Created:** [June 28, 2017, 11:57pm UTC](https://forums.fusetools.com/t/edit-androidmanifest-attributes/6677 "2017-06-28T23:57:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesusmartinoza](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jesusmartinoza/32/659_2.png) [@jesusmartinoza](https://forums.fusetools.com/u/jesusmartinoza)\
**Post date:** [June 28, 2017, 11:57pm UTC](https://forums.fusetools.com/t/edit-androidmanifest-attributes/6677/1 "2017-06-28T23:57:56Z")

</div>

Hi 🙂 I would like to add `tools:replace="allowBackup, label"` attribute to my AndroidManifest to avoid this kind of errors with gradle libraries:

```auto
/Users/jesusmartinez/FuseProjects/Fuse.Conekta/Example/build/Android/Preview/app/src/main/AndroidManifest.xml:20:18-45 Error:
	Attribute application@allowBackup value=(false) from AndroidManifest.xml:20:18-45
	is also present at [io.conekta:conektasdk:2.1] AndroidManifest.xml:12:9-35 value=(true).
	Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:17:5-64:19 to override.
/Users/jesusmartinez/FuseProjects/Fuse.Conekta/Example/build/Android/Preview/app/src/main/AndroidManifest.xml:17:18-51 Error:
	Attribute application@label value=(Example (preview)) from AndroidManifest.xml:17:18-51
	is also present at [io.conekta:conektasdk:2.1] AndroidManifest.xml:13:9-41 value=(@string/app_name).
	Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:17:5-64:19 to override.

```

This seems not to work  
`[Require("AndroidManifest.RootElement", "<application tools:replace=\"android:label\"/>")]`

Any idea how to solve it?

---

<div class="post-metadata">

**Author:** ![Uldis](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/uldis/32/657_2.png) [@Uldis](https://forums.fusetools.com/u/Uldis)\
**Post date:** [June 30, 2017, 8:49am UTC](https://forums.fusetools.com/t/edit-androidmanifest-attributes/6677/2 "2017-06-30T08:49:13Z")

</div>

Hi,

currently there is no way to add arbitrary attributes to the `<application />` node in `AndroidManifest.xml`. You will need to add that manually, and then use the `build.sh`/`build.bat` script to rebuild the APK after changing the manifest.

---

<div class="post-metadata">

**Author:** ![Mitch\_Hymel](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@Mitch\_Hymel](https://forums.fusetools.com/u/Mitch_Hymel)\
**Post date:** [August 7, 2017, 12:04am UTC](https://forums.fusetools.com/t/edit-androidmanifest-attributes/6677/3 "2017-08-07T00:04:44Z")

</div>

I had the same problem, and while the manual solution definitely works, it’s very annoying to have to update the file every build. You can definitely automate this type of thing with gradle. I’m not a gradle expert, and the below solution might be “hacky”, but it’s worked for me so far.

Essentially, what you want to do is write a gradle task that will modify your manifest file, and make sure this task runs before the manifest is needed. What I did was create a uxl file and make sure to include it in my unoproj. The contents of the uxl file would look something like below.

NOTE: I haven’t figured out how to get the manifest file path based on build variant/flavor from gradle, so I’ve just been using the full absolute path to my manifest.

```auto
<Extensions Backend="CPlusPlus">
  <Require Condition="Android" Gradle.BuildFile.End>
    <![CDATA[
      // define the task
      task updateManifest(type: UpdateManifestTask)

      // implement the task
      class UpdateManifestTask extends DefaultTask {
        @TaskAction
        def update() {

          // find the manifest and get the contents
          // TODO: use gradle to find manifest path based on variant/flavor
          def manifestPath = "C:/Dev/Fuse/GameTime/build/Android/Debug/app/src/main/AndroidManifest.xml"
          def manifestFile = new File(manifestPath)
          def content = manifestFile.getText()

          // update content, in our case, find and replace some string
          def updatedContent = content.replaceAll("android:allowBackup=\"false\"", "android:allowBackup=\"true\"")
          manifestFile.write(updatedContent)
        }
      }

      // make processDebugManifest task depend on our new task to ensure the manifest is updated when it's needed
      afterEvaluate {
        processDebugManifest.dependsOn updateManifest
      }
    ]]>
  </Require>
</Extensions>

```

---

<div class="post-metadata">

**Author:** ![jesusmartinoza](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/jesusmartinoza/32/659_2.png) [@jesusmartinoza](https://forums.fusetools.com/u/jesusmartinoza)\
**Post date:** [August 7, 2017, 5:06am UTC](https://forums.fusetools.com/t/edit-androidmanifest-attributes/6677/4 "2017-08-07T05:06:40Z")

</div>

Thank you very much for sharing Mitchell (: That solution looks great! I ended replacing the entire AndroidManifest using UXL.  
Here is the result: [https://github.com/jesusmartinoza/Fuse.Conekta/blob/master/src/android\_support.uxl](https://github.com/jesusmartinoza/Fuse.Conekta/blob/master/src/android_support.uxl)
