Android Studio Gradle 图标错误,清单合并
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24506800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android studio Gradle icon error, Manifest Merger
提问by shimi_tap
I keep seeing this message and not sure how to solve it for good.
我一直看到这条消息,但不知道如何永久解决它。
Error:(43, 9) Attribute application@icon value=(@drawable/new_app_icon) from AndroidManifest.xml:43:9
is also present at com.github.erizet.signala:signala-longpolling:0.20:7:18 value=(@drawable/ic_launcher)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:40:5 to override
:OpenBook:processDebugManifest FAILED
Error:Execution failed for task ':OpenBook:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
Tried adding android:replace="android:icon"
to my manifest even with my icon.
android:replace="android:icon"
即使使用我的图标,也尝试添加到我的清单中。
I tried deleting the android:icon="@drawable/ic_launcher
from the library but it keeps coming back when i build because its imported from maven
我尝试android:icon="@drawable/ic_launcher
从库中删除它 ,但它在我构建时不断返回,因为它是从 maven 导入的
Any ideas ?
有任何想法吗 ?
回答by shimi_tap
It seems to be the fault of the mainfest Merger tool for gradle.
这似乎是 gradle 的主要合并工具的错。
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
Solved it by adding to my manifest tag xmlns:tools="http://schemas.android.com/tools"
通过添加到我的清单标签解决了它 xmlns:tools="http://schemas.android.com/tools"
Then added tools:replace="android:icon,android:theme"
to the application tag
然后添加tools:replace="android:icon,android:theme"
到应用程序标签
This tells the merger to use my manifest icon and theme and not of other libraries
这告诉合并使用我的清单图标和主题,而不是其他库
Hope it helps thanks
希望有帮助谢谢
回答by Mina Fawzy
I have same issue , I fix it like this by adding xmlns:tools="http://schemas.android.com/tools"
to the top of mainfest file , and add tools:replace="android:icon"
to be look like
我有同样的问题,我通过添加xmlns:tools="http://schemas.android.com/tools"
到 mainfest 文件的顶部来修复它,并添加tools:replace="android:icon"
看起来像
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" // add tools line here
package="yourpackage">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:replace="android:icon"> ///add this line
.....
</application>
</manifest>
回答by Adnan Abdollah Zaki
i have same error , just this code solve my problem , i want to share with you :
我有同样的错误,只是这段代码解决了我的问题,我想与您分享:
in Manifest.xml
:
在Manifest.xml
:
add this code in top of your xml file :
xmlns:tools="http://schemas.android.com/tools"
Then added :
tools:replace="android:icon,android:theme,android:label,android:name"
to the application tag
将此代码添加到您的 xml 文件顶部:
xmlns:tools="http://schemas.android.com/tools"
然后补充说:
tools:replace="android:icon,android:theme,android:label,android:name"
到应用程序标签
回答by u5172180
The answer of shimi_tap is enough.
What to be remembered is that choosing only what you need. Choose from {icon, name, theme, label}.
I added tools:replace="android:icon,android:theme"
, it does not work. I added tools:replace="android:icon,android:theme,android:label,android:name"
, it does not work. It works when I added tools:replace="android:icon,android:theme,android:label"
. So find out what the conflict exactly is in your manifest files.
shimi_tap 的回答就够了。需要记住的是,只选择你需要的。从{图标、名称、主题、标签}中选择。我补充说tools:replace="android:icon,android:theme"
,它不起作用。我补充说tools:replace="android:icon,android:theme,android:label,android:name"
,它不起作用。当我添加tools:replace="android:icon,android:theme,android:label"
. 因此,找出清单文件中的冲突到底是什么。
回答by Ilya Cucumber
Just add xmlns:tools="http://schemas.android.com/tools"
to your manifest tag, and then you need to add tools:replace="android:icon"
beforeandroid:icon="@mipmap/ic_launcher"
.
只需添加xmlns:tools="http://schemas.android.com/tools"
到您的清单标签,然后您需要tools:replace="android:icon"
在android:icon="@mipmap/ic_launcher"
.
回答by Hisham Muneer
This error also occurs when your app's minSdk is higher than any library's minSdk.
当您的应用程序的 minSdk 高于任何库的 minSdk 时,也会发生此错误。
app's minSdk >= libraries minSdk
回答by Alecs
I had this problem changing the icon from drawable to mipmap.
我在将图标从 drawable 更改为 mipmap 时遇到了这个问题。
I only missed the line
我只是错过了线路
tools:replace="android:icon"
tools:replace="android:icon"
in the manifest.
在清单中。
回答by Ismael ozil
GOT THE SOLUTION AFTER ALOT OF TIME GOOGLING
经过长时间的谷歌搜索后得到了解决方案
just get your ic_launcherand paste it in your drawables folder,
只需获取您的ic_launcher并将其粘贴到您的 drawables 文件夹中,
Go to your manifest and change android:icon="@drawable/ic_launcher"
转到您的清单并更改 android:icon="@drawable/ic_launcher"
Clean your project and rebuild
清理你的项目并重建
Hope it helps you
希望对你有帮助
回答by Ricardo Mutti
If nothing of that work, close Android Studio. Go on app/src/main, open the file AndroidManifest.xml in a text editor (like sublime), remove/replace the erros lines, save and reopen android studio.
如果这些都不起作用,请关闭 Android Studio。转到 app/src/main,在文本编辑器(如 sublime)中打开文件 AndroidManifest.xml,删除/替换错误行,保存并重新打开 android studio。
回答by Alex
For some reason android studio doesn't like calling app icon from drawable folder. So in that case I created mipmap resource directory under res folder.
出于某种原因,android studio 不喜欢从可绘制文件夹中调用应用程序图标。所以在这种情况下,我在 res 文件夹下创建了 mipmap 资源目录。
Right click res folder > new > android resource directory > resource type: mipmapand now drop any icon in there then reference that into manifest file. Sharing this since this method worked for me.
右键单击 res 文件夹 > 新建 > android 资源目录 > 资源类型:mipmap,现在将任何图标放入其中,然后将其引用到清单文件中。分享这个,因为这种方法对我有用。
android:icon:@drawable/ic_launcher"
android:icon:@drawable/ic_launcher"
to
到
android:icon="@mipmap/ic_launcher"
android:icon="@mipmap/ic_launcher"