Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tools: replace not replacing in Android manifest

I am using a gradle project with many different library dependencies and using the new manifest merger. In my <application /> tag I have it set up as such:

<application tools:replace="android:icon, android:label, android:theme, android:name"     android:name="com.example.myapp.MyApplcation"     android:allowBackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/application_name"     android:logo="@drawable/logo_ab"     android:theme="@style/AppTheme"     > .... </application> 

Yet I am receiving the error:

/android/MyApp/app/src/main/AndroidManifest.xml:29:9        Error: Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:29:9 is also present at {Library Name} value=(@drawable/app_icon) Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:26:5 to override  /android/MyApp/app/src/main/AndroidManifest.xml:30:9 Error: Attribute application@label value=(@string/application_name) from AndroidManifest.xml:30:9 is also present at {Library Name} value=(@string/app_name) Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:26:5 to override  /android/MyApp/app/src/main/AndroidManifest.xml:27:9 Error: Attribute application@name value=(com.example.myapp.MyApplication) from AndroidManifest.xml:27:9 is also present at {Another Library}  Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml:26:5 to override  /android/MyApp/app/src/main/AndroidManifest.xml:32:9 Error: Attribute application@theme value=(@style/AppTheme) from AndroidManifest.xml:32:9 is also present at {Library Name} value=(@style/AppTheme) Suggestion: add 'tools:replace="android:theme"' to <application> element at AndroidManifest.xml:26:5 to override 
like image 560
agrosner Avatar asked Sep 22 '14 18:09

agrosner


People also ask

How do I fix a failed manifest merger?

The initial process would be to open the manifest application known as the AndroidManifest. xml and then click on the Merged Manifest tab below your edit pane. Following which, Click on the merged manifest option. An Error would be visible at the right column and then one must try to solve the error.

What is supportsRtl?

android:supportsRtl="true" enables support for right-to-left languages. Without this, layout will always be left-to-right, However by itself it does not change the layout to be from right to left. It simply enables other attributes - one of those new attributes controls whether is left-to-right or right-to-left.

How do I change AndroidManifest XML?

The Android manifest file is a specially formatted XML file. You can edit the XML manually by clicking on the AndroidManifest. xml tab. Android manifest files generally include a single <manifest> tag with a single <application> tag.


2 Answers

Declare your manifest header like this

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

Then you can add to your application tag the following attribute:

<application     tools:replace="icon, label" ../> 

For example I need to replace icon and label. Good luck!

like image 51
Andrus Avatar answered Sep 28 '22 11:09

Andrus


I fixed same issue. Solution for me:

  1. add the xmlns:tools="http://schemas.android.com/tools" line in the manifest tag
  2. add tools:replace=.. in the manifest tag
  3. move android:label=... in the manifest tag

Example:

 <?xml version="1.0" encoding="utf-8"?>     <manifest xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"               tools:replace="allowBackup, label"               android:allowBackup="false"               android:label="@string/all_app_name"/> 
like image 36
stefan K Avatar answered Sep 28 '22 11:09

stefan K