tools:replace="android:icon doesn't work - android

I use :
Android Studio 2.2.2
Compile SDK version : API 23
Build Tool Version 23.0.2
I'm trying to use SweetAlert for Android library for dialogs in my android application
so after i add compile 'cn.pedant.sweetalert:library:1.3' to my dependencies i got this error
Attribute application#icon value=(#mipmap/launcher) from
AndroidManifest.xml:19:9-40 is also present at
[com.pnikosis:materialish-progress:1.0] AndroidManifest.xml:13:9-45
value=(#drawable/ic_launcher). Suggestion: add
'tools:replace="android:icon"' to element at
AndroidManifest.xml:16:5-56:19 to override.
AndroidManifest.xml :
<application
android:name=".utils.MyApp"
android:allowBackup="true"
android:icon="#mipmap/launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme.Red"
tools:replace="android:icon">

Add xmlns:tools="http://schemas.android.com/tools" in the manifest tag at your AndroidManifest.xml file. Notice the http:// before schemas.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.your.app">

Related

Facing error during Merging manifest file in android studio

I added PAYTM SDK in my project and now I am facing a problem with merging manifest file since the library has its own manifest file.
So I am getting
> Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application#icon value=(#mipmap/logo) from AndroidManifest.xml:19:9-42
is also present at [com.paytm.pgsdk:pgsdk:1.0.6] AndroidManifest.xml:12:9-45 value=(#drawable/ic_launcher).
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:16:5-178:19 to override.
But after adding tools:replace="android:icon" in my application tag, my app has crashed at runtime by the following exception.
Caused by: java.lang.IllegalStateException: You need to use a
Theme.AppCompat theme (or descendant) with this activity.
Here is my manifest file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.demo">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
tools:replace="android:icon"
android:icon="#mipmap/login_logo"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">
.
.
.
</application>
Just remove icon="#mipmap/login_logo" and theme="#style/AppTheme" from your Application Manifest and replace drawable ic_launcher in PayTM SDK with your app logo and that would do it.
Application will merge both manifests and you will get your desired theme and logo will be fetched from PayTM's manifest hence you would have replaced their ic_launcher with yours.
Finally, I have solved that theme issue by removing conflicting AppTheme's style from SDK.

add 'tools:replace="Android:value"' to <meta-data> element at AndroidManifest

I'm following a tutorial in HeadFirst Android development and encountered issues after adding:
private ActionBarDrawerToggle drawerToggle;
The control was deprecated so I followed instructions on Stack to resolve that issue by adding com.android.support:appcompat-v7:26.0.0-alpha1 to the app modules Dependencies
But now I'm getting the following build errors:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(25.3.1) from [com.android.support:recyclerview-v7:25.3.1] AndroidManifest.xml:24:9-31
is also present at [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:22:5-24:34 to override.
Here is the code:
Problem is that all support libraries with same version and major version has to match compile SDK version.
So try to force a specific support library version.
Put this at the end of your app module in build.gradle.
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
First add this line to your manifest tag if you do not have yet:
xmlns:tools="http://schemas.android.com/tools"
Example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.winanainc"
android:versionCode="3"
android:versionName="1.2"
xmlns:tools="http://schemas.android.com/tools">
Then Add this meta tag inside your application to overwrite you build tools version, in this case for example I choosed the version 25.3.1
<application>
...
..
<meta-data
tools:replace="android:value"
android:name="android.support.VERSION"
android:value="25.3.1" />
</application>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme"
>
<meta-data
tools:replace="android:value"
android:name="android.support.VERSION"
android:value="26.0.0" />
</application>
Changed all support library versions to 25.3.1 and worked like a charm:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
You also need to change the following parameters to 25:
compileSdkVersion 25
targetSdkVersion 25
Add <meta-data> tag in manifest.xml file as below...
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.demo"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
**<meta-data
tools:replace="android:value"
android:name="android.support.VERSION"
android:value="25.3.1" />//this 25.3.1 version should be same which we defined in the build.gradle file. i am using compileSdkVersion 25**
</application>
</manifest>
it will work #Ambilpura....
Open Android Studio -> Open Manifest File
Add <uses-sdk tools:overrideLibrary="android.support.v17.leanback"/>. Don't forget to include xmlns:tools="http://schemas.android.com/tools" too, before the <application> tag
replace
compile 'com.android.support:recyclerview-v7:+'
by
compile 'com.android.support:recyclerview-v7:25.3.1'
and add
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
I've tried all solution but nothing work. After reading google docs I have found my solution that fixed my manifest merge issue.
Just add this simple line in manifest file:
<application
...
tools:node="replace"
...
</application>
This fixed my issue.
If this doesn't work then try with these,
tools:node="merge-only-attributes"
tools:node="removeAll"
tools:node="replace"
You can find google docs from this link.
Merge multiple manifest files
At Android Studio -> Open Manifest File
Switch to Merged Manifest and check Other Manifest file.
In my case I am using 26.1.0 support files but found support-v13 is 26.0.1
So I added implementation 'com.android.support:support-v13:26.1.0' to Gradle file and problem solved
the answer by #sagar giri is a temporary work around. what i did to solve this is explained at the end.
If you have latest support library installed in latest android studio and if you have a old support library version in build gradle's app module, then android studio fails due to the version mismatch.
So update your support library version to latest one and fix latest support library changes like icon renaming etc and rebuild it.
hope it helps...
This code resolved my problem
"Problem is that all support libraries with same version and major version has to match compile SDK version.
So try to force a specific support library version. Put this at the end of your app module in build.gradle."
thanks
Whenever you face this issue, the best approach is to run Rebuild Project - this will tell you exactly why this is happening.
In my case it was a meta-data present in both module and app
add 'tools:replace="android:value"' to element at AndroidManifest.xml:22:5-24:34 to override.
add to Line AndroidManifest.xml:22

Manifest Merger failed with multiple errors in Android Studio

So, I am a beginner into Android and Java. I just began learning. While I was experimenting with Intent today, I incurred an error.
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
I found some solutions here and tried to implement them, but it did not work.
This is my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.rohan.petadoptionthing"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
}
This is my AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
package="com.example.rohan.petadoptionthing" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Second"
/>
<activity android:name=".third"/>
<activity android:name=".MainActivity"/>
</application>
This is my first week with coding, I am sorry if this is a really silly thing. I am really new to this and did not find any other place to ask. Sorry if I broke any rules
Open application manifest (AndroidManifest.xml) and click on Merged Manifest tab on bottom of your edit pane. Check the image below:
From image you can see Error in the right column, try to solve the error. It may help some one with the same problem. Read more here.
Also, once you found the error and if you get that error from external library that you are using, You have to let compiler to ignore the attribute from the external library.
//add this attribute in application tag in the manifest
tools:replace="android:allowBackup"
//Add this in the manifest tag at the top
xmlns:tools="http://schemas.android.com/tools"
Remove <activity android:name=".MainActivity"/> from your mainfest file. As you have already defined it as:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
So, Manifest file showing ambiguity.
For me THIS works -
Finding Merging Errors in AndroidManifest.xml
Click on Merged Manifest in AndroidManifest.xml
You can view manifest merging error in right column. It may help to solve this problem.
I was also facing same issues, and after lot of research found the solution:
Your min sdk version should be same as of the modules you are using eg: your module min sdk version is 14 and your app min sdk version is 9 It should be same.
If build version of your app and modules not same. Again it should same
** In short, your app build.gradle file and manifest should have same configurations**
There's no duplicacy like same permissions added in manifest file twice, same activity mention twice.
If you have delete any activity from your project, delete it from your manifest file as well.
Sometimes its because of label, icon etc tag of manifest file:
a) Add the xmlns:tools line in the manifest tag.
b) Add tools:replace= or tools:ignore= in the application tag.
Example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.slinfy.ikharelimiteduk"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="1"
android:versionName="1.0" >
<application
tools:replace="icon, label"
android:label="myApp"
android:name="com.example.MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="#drawable/ic_launcher"
android:theme="#style/Theme.AppCompat" >
</application>
</manifest>
If two dependencies are of not same version
example: you are using dependency for appcompat v7:26.0.0 and for facebook com.facebook.android:facebook-android-sdk:[4,5)
facebook uses cardview of version com.android.support:cardview-v7:25.3.1 and appcompat v7:26.0.0 uses cardview of version v7:26.0.0, So there is discripancy in two libraries and thus give error
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute meta-data#android.support.VERSION#value value=(26.0.0-alpha1) from [com.android.support:appcompat-v7:26.0.0-alpha1] AndroidManifest.xml:27:9-38
is also present at [com.android.support:cardview-v7:25.3.1] AndroidManifest.xml:24:9-31 value=(25.3.1).
Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:41 to override.
So by using appcompat of version 25.3.1, We can avoid this error
By considering above points in mind, you will get rid of this irritating issue.
You can check my blog too
https://wordpress.com/post/dhingrakimmi.wordpress.com/23
Just add below code in your project Manifest application tag...
<application
tools:node="replace">
If your project targeted Android 12 then
Add this in all <activity> tags with <intent-filter>
android:exported="true/false"
In addition to available solutions, please check this also.If you have set android:allowBackup="false" in your AndroidManifest.xml then there may be a conflict for android:allowBackup="true" in other dependencies.
Solution
As suggested by #CLIFFORD P Y, switch to Merged Manifest in your AndroidManifest.xml. Android Studio will suggest to add tools:replace="android:allowBackup" in <application /> in your AndroidManifest.xml.
I was facing the same problem and I've just added one line in my manifest.xml and it worked for me.
tools:replace="android:allowBackup,icon,theme,label,name">
add this line under
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="#drawable/launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="#style/AppThemecustom"
tools:replace="android:allowBackup,icon,theme,label">
Hope it will help.
I solved this with Refactor -> Migrate to AndroidX
GL
In my case it was showing an error because there was a redundancy in <uses-permission> element.
So, please check in your AndroidManifest.xml file for the same.
Android Studio version is 3.0.1
Operating System is Windows 7
Here is the screenshot for reference.
Usually occurs when you have errors in your manifest.Open AndroidManifest.xml .Click on the merged manifest tab.The errors can be seen there .Also include suggestions mentioned there.When I had a similar problem while importing com.google.android.gms.maps.model.LatLng ,it suggested me to include tools:overrideLibrary="com.google.android.gms.maps" in the application tag and the build was successful.
solution for me was like this:
1- open manifest
2-On top right , check highlighted problems like below:
3-click on problems icon in red. this will open problems tab like below.
4- solve them one by one
I was also facing this error. In the build log the last line was "Failed to compile values file".
So if you're facing the same issue, then just adding the following line in the gradle.properties file will most probably fix the issue.
android.enableJetifier=true
I mean it fixed Manifest Merger failed with multiple errors in Android Studio error for me.
My case i have fixed it by
build.gradle(Module:app)
defaultConfig {
----------
multiDexEnabled true
}
dependencies {
...........
implementation 'com.google.android.gms:play-services-gcm:11.0.2'
implementation 'com.onesignal:OneSignal:3.+#aar'
}
This answer releted to OnSignal push notification
If after you add a Android Library Module and you get this error.
You can fix it by simple remove the android:label="#string/app_name" from the AndroidManifest.xml of your Android Library Module
In AndroidManifest.xml:
At application, add tools:replace="android:icon, android:theme and
At the Manifest root, add xmlns:tools="http://schemas.android.com/tools
In build.gradle:
At root, add useOldManifestMerger true
The minium sdk version should be same as of the modules/lib you are using
For example: Your module min sdk version is 26 and your app min sdk version is 21 It should be same.
I see the answers and they are complete and useful. Anyway, if you are completing the Jetpack Compose Testing codelab and you find this error in late 2021, the solution is not the accepted answer, you need to downgrade your target sdk version to 30.
In app/build.gradle, replace:
targetSdkVersion 31
with:
targetSdkVersion 30
And run the Android Tests again
for the past few days I was also going through the same issue. But after, a lot of research I finally found a solution for this.
In order to solve this issue, what you need to do is:
1. Check if your project's build.gradle file and the module's build.gradle file contain same versions of all dependencies.
2. Make sure, your project's compileSdkVersion, buildToolsVersion, minSdkVersion and targetSdkVersion matches the one in the modules or libraries that you have added into the project.
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.appname"
minSdkVersion 16
targetSdkVersion 25
versionCode 22
versionName "2.0.3"
}
Hope, this helps.
Open your gradle console, then you see gradle suggest you to add the particular line (Like: tools:replace="android:allowBackup" or tools:replace="android:label" etc). Add that line into your manifest file under tag and sync gradle, that's it.
In my case it happened for leaving some empty intent-filter inside the Activity tag
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
</intent-filter>
</activity>
So just removing them solved the problem.
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
</activity>
The following hack works:
Add the xmlns:tools="http://schemas.android.com/tools" line in the
manifest tag
Add
tools:replace="android:icon,android:theme,android:allowBackup,label,name"
in the application tag
I was using the FirebaseUI Library along with the Facebook SDK Library, which was causing me the issue.
implementation 'com.firebaseui:firebase-ui-database:0.4.4'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
And from [here][1], I got rid of this issue.
With the latest update of FirebaseUI library, previous version of Facebook SDK is also a part of it.
If you are using the both the libraries, please remove the Facebook SDK Library.
https://github.com/firebase/FirebaseUI-Android/issues/230
UPDATE
From the Android Studio 3.0 and the later versions, app.gradle file is required to use implementation or api instead of compile for adding the dependencies to the app.
This error occurs because you don't have proper statements at the Manifest root such:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.test">
So you should remove additional texts in it.
In my case, I solved it by updating the classpath in build.gradle (Project) file to the latest version.
It was like this:
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
After updating to the latest version:
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
}
Everything worked fine! Hope this helps someone if all the above answers don't solve the issue.
As a newbie to Android Studio, in my case, I had moved an existing project from Eclipse to Android Studio and found that there was a duplicate definition of an activity within my Manifest.xml that hadn't been picked up by Eclipse was shown as a Gradle error.
I found this by going to the Gradle Console (bottom right of the screen).
Happened with me twice when I refractor (Rename with SHIFT + F6) the name of a field in our files and it asks you to change it everywhere and we without paying attention change the name everywhere.
For example, if you have a variable name "id" in your Java class and you rename it with SHIFT + F6. If you don't pay attention to the next dialog which will ask you wherever else it is going to change the id and you tick check all it will change all the id in your layout files from the new value.
this is very simple error only occur when you define any activity call two time in mainifest.xml file Example like
<activity android:name="com.futuretech.mpboardexam.Game" ></activity>
//and launcher also------like that
//solution:use only one
Put this at the end of your app module build.gradle:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}}
from this
Supplement the answer Phan Van Linh. I deleted these lines:
android:icon="#mipmap/ic_launcher"
android:label="name"

android manifest merger cannot merge three manifest files

i have 2 versions of AndroidManifest.xml files in my project, one is the main and another for debug.
in both of them i have android:label and in the debug version i have tools:replace="label"
after adding a library through gradle i suddenly see:
Error:Execution failed for task ':app:processMobileDebugManifest'.
Manifest merger failed : Attribute application#label value=(XXXX Debug) from AndroidManifest.xml:36:13-45
is also present at [library_name] AndroidManifest.xml:13:9-41 value=(#string/app_name).
Suggestion: add 'tools:replace="android:label"' to element at AndroidManifest.xml:7:5-20:19 to override.
it already exists there! what am i doing wrong?
Edit1:
main xml:
<application
android:name="[package_name]"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
debug xml:
<application
tools:replace="name, label"
android:name="[package_name]"
android:label="[debug_name]">
third party library xml:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
I found out that the label should have the same value like all others.
Meaning that tools:replace works only if all labels looks like this:
android:label="#string/app_name"
In my case it didn't work because in the debug manifest it looked like this:
android:label="debug name"
But once i changed it to android:label="#string/app_name" and added string in the debug/values dir it started working correctly.
Seems like a bug in Android Studio.

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
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.
I fixed same issue. Solution for me:
add the xmlns:tools="http://schemas.android.com/tools" line in the manifest tag
add tools:replace=.. in the manifest tag
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"/>
Try reordering your dependencies in your gradle file. I had to move the offending library from the bottom of the list to the top, and then it worked.
I just experienced the same behavior of tools:replace=... as described by the OP.
It turned out that the root cause for tools:replace being ignored by the manifest merger is a bug described here. It basically means that if you have a library in your project that contains a manifest with an <application ...> node containing a tools:ignore=... attribute, it can happen that the tools:replace=... attribute in the manifest of your main module will be ignored.
The tricky point here is that it can happen, but does not have to. In my case I had two libraries, library A with the tools:ignore=... attribute, library B with the attributes to be replaced in the respective manifests and the tools:replace=... attribute in the manifest of the main module. If the manifest of B was merged into the main manifest before the manifest of A everything worked as expected. In opposite merge order the error appeared.
The order in which these merges happen seems to be somewhat random. In my case changing the order in the dependencies section of build.gradle had no effect but changing the name of the flavor did it.
So, the only reliable workaround seems to be to unpack the problem causing library, remove the tools:ignore=... tag (which should be no problem as it is a hint for lint only) and pack the library again.
And vote for the bug to be fixed, of cause.
Final Working Solution for me (Highlighted the tages in the sample code):
add the xmlns:tools line in the manifest tag
add tools:replace in the application tag
Example:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pagination.yoga.com.tamiltv"
**xmlns:tools="http://schemas.android.com/tools"**
>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
**tools:replace="android:icon,android:theme"**
>
The missing piece for me was this:
xmlns:tools="http://schemas.android.com/tools"
for example:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.your.appid">
You can replace those in your Manifest application tag:
<application
tools:replace="android:icon, android:label, android:theme, android:name,android:allowBackup"
android:allowBackup="false"...>
and will work for you.
The following hack works:
add the xmlns:tools="http://schemas.android.com/tools" line in the
manifest tag
add
tools:replace="android:icon,android:theme,android:allowBackup,label"
in the application tag
tools:replace="android:supportsRtl,android:allowBackup,icon,label">
FIXED IT
HAD THE EXACT ERROR, Just add this tools:replace="android:icon,android:theme"
into your application tag in your manifest,
it works just fine,
You can replace those in your Manifest application tag:
<application
...
tools:replace="android:label, android:icon, android:theme"/>
and will work for you.
Explanation
Using such a dependency/library in your gradle file which has those labels in its Manifest's application tag may produce this problem and replacing them in your Manifest is the solution.
My problem is multi modules project with base module, app module and feature module.
Each module has AndroidManifest of its own, and I implemented build variant for debug and main.
So we must sure that "android:name" just declared in Manifest of debug and main only, and do not set it in any of Manifest in child module.
Ex:
Manifest in main:
<application
android:name=".App"/>
Manifest in debug:
<application
tools:replace="android:name"
android:name=".DebugApp"
/>
Do not set "android:name" in other Manifest files like this:
<application android:name=".App">
Just define in feature module like this and it will merged fine
<application>
I also went through this problem and changed that:
<application android:debuggable="true" android:icon="#drawable/app_icon" android:label="#string/app_name" android:supportsRtl="true" android:allowBackup="false" android:fullBackupOnly="false" android:theme="#style/UnityThemeSelector">
to
<application tools:replace="android:allowBackup" android:debuggable="true" android:icon="#drawable/app_icon" android:label="#string/app_name" android:supportsRtl="true" android:allowBackup="false" android:fullBackupOnly="false" android:theme="#style/UnityThemeSelector">
I was receiving a similar error on a project I was importing:
Multiple entries with same key: android:icon=REPLACE and
tools:icon=REPLACE
Fixed after changing the below line within the application tag:
tools:replace="icon, label, theme"
to
tools:replace="android:icon, android:label, android:theme"
This is new androidManifest.xml for flutter
<application
android:label="Your app Name"
tools:replace="android:label"
android:name="io.flutter.app.FlutterApplication"
android:networkSecurityConfig="#xml/network_security_config"
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
please make to add android:label in the first line in <application, 'cause if you are using this package flutter_app_name will throw an error if the not sorted like example Above

Categories

Resources