はじめに

Androidのライブラリを導入時にManifestファイルで競合が発生し、実行できなくなったので改善案をメモしてます。

エラー発生から解決まで

Androidのライブラリを導入時にManifestファイルでiconの競合たるエラーが発生しました。
恐らく、ライブラリとiconで競合しどちらを優先するべきかコンパイラがわからなくなってのエラーと思います。

エラー詳細:

Error:(9, 9) Attribute application@icon value=(@drawable/ic_launcher.png) from AndroidManifest.xml:9:9
Error:(9, 9) Execution failed for task ‘:app:processDebugManifest’.
> Manifest merger failed : Attribute application@icon value=(@drawable/ic_launcher.png) from AndroidManifest.xml:9:9
is also present at com.github.example:1.0.0:13:9 value=(@drawable/ic_launcher)
Suggestion: add ‘tools:replace=”android:icon”‘ to element at AndroidManifest.xml:7:5 to override

解決方法

エラー詳細に記載されている通り競合したプロジェクトのiconをreplaceすることで無事実行できました。

まずManifestファイルのmanifestタグを修正します
xmlns:tools=”http://schemas.android.com/tools”を追加します

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

次にManifestファイルのapplicationタグを修正します
tools:replace=”android:icon”の追加します

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        tools:replace="android:icon"
        android:theme="@style/AppTheme" >

ここまでで改善しました

その他おすすめの備忘録

Tagged with:
 

コメントを残す