• 欢迎浏览“String me = Creater\忠实的资深Linux玩家;”,请文明浏览,理性发言,有侵犯你的权益请邮件我(creater@vip.qq.com).
  • 把任何的失败都当作一次尝试,不要自卑;把所有的成功都想成是一种幸运,不要自傲。
  •    3年前 (2015-10-04)  Android |   抢沙发  24 
    文章评分 0 次,平均分 0.0

    今天一技术群里的朋友碰到个问题,说用Android Studio导入第三方依赖库时报错,出现这个:

    解决Android Studio添加依赖时出现“Manifest merger failed”

    所导入的依赖为这个

    SweetAlertDialog:
    https://github.com/pedant/sweet-alert-dialog

    于是多管闲事的我试着导入了下,也出错了,不过没出现上面截图的错误,而出现Manifest merger failed(Manifest合并失败)错误,如下图:

    解决Android Studio添加依赖时出现“Manifest merger failed”

    <span class="line">1</span>
    <span class="line">2</span>
    <span class="line">3</span>
    <span class="line">4</span>
    <span class="line">5</span>
    <span class="line"><span class="string">Error:</span>(<span class="number">7</span>, <span class="number">9</span>) Attribute application<span class="annotation">@icon</span> value=(<span class="annotation">@mipmap</span>/ic_launcher) from AndroidManifest.<span class="string">xml:</span><span class="number">7</span>:<span class="number">9</span></span>
    <span class="line"><span class="string">Error:</span>(<span class="number">7</span>, <span class="number">9</span>) Execution failed <span class="keyword">for</span> task <span class="string">':importdemo:processDebugManifest'</span>.</span>
    <span class="line">&gt; Manifest merger <span class="string">failed :</span> Attribute application<span class="annotation">@icon</span> value=(<span class="annotation">@mipmap</span>/ic_launcher) from AndroidManifest.<span class="string">xml:</span><span class="number">7</span>:<span class="number">9</span></span>
    <span class="line">    is also present at com.<span class="string">pnikosis:</span>materialish-<span class="string">progress:</span><span class="number">1.0</span>:<span class="number">13</span>:<span class="number">9</span> value=(<span class="annotation">@drawable</span>/ic_launcher)</span>
    <span class="line"><span class="label">        Suggestion:</span> add <span class="string">'tools:replace="android:icon"'</span> to &lt;application&gt; element at AndroidManifest.<span class="string">xml:</span><span class="number">5</span>:<span class="number">5</span> to override</span>

    解决Android Studio添加依赖时出现“Manifest merger failed”

    分析错误提示,

    1. 主程序module清单文件中,application节点的android:icon属性引用了@mipmap/ic_launcher图片资源,
    2. 而依赖module的清单文件中,同样的android:icon属性却引用了@drawable/ic_launcher这个图片资源,

    两个属性值产生冲突,导致合并清单文件失败。

    虽然知道错误是什么,但是仍然不知道咋解决啊。
    其实英语没那么糟糕,细心点的话,就能看到错误提示中就给出了解决问题的建议。

    Suggestion: add ‘tools:replace=”android:icon”‘ to element at AndroidManifest.xml:5:5 to override

    意思在AndroidManifest.xml文件的<application>节点中添加tools:replace="android:icon"属性。

    解决Android Studio添加依赖时出现“Manifest merger failed”

    按提示进行修改,再同步Gradle,问题解决。

    tools:replace 属性的作用可以在这个页面找到(需要搭梯)
    http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
    在页面搜索 Override an attribute coming from a library 即可定位到。

     

    除特别注明外,本站所有文章均为String me = "Creater\忠实的资深Linux玩家";原创,转载请注明出处来自http://unix8.net/home.php/4282.html

    关于

    发表评论

    暂无评论

    切换注册

    登录

    忘记密码 ?

    切换登录

    注册

    扫一扫二维码分享