1. 程式人生 > >Error:Attribute [email protected]

Error:Attribute [email protected]

今天在匯入一個emoji的控制元件的時候提示Error:(14, 9) Attribute [email protected] value=(@drawable/ic_launcher) from AndroidManifest.xml:14:9

百度了一下,這是一個編譯的常見錯誤,主要是AS的Gradle外掛預設會啟用Manifest Merger Tool,若Library專案中也定義了與主專案相同的屬性(例如預設生成的android:icon和android:theme),則此時會合並失敗,並報上面的錯誤。

可惜看的那篇文章的解決方法講的不清不楚,依然沒有搞懂要怎麼弄,於是找到另一篇文章中有完整的程式碼,一目瞭然。

注意修改的地方在於第2行的

xmlns:tools="http://schemas.android.com/tools"

和application最後一行的

tools:replace="android:icon, android:theme"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.leo.kang.demo"
    android:versionCode=
"1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"
tools:replace="android:icon, android:theme">