1.合并AndroidManifest错误
D:\AndroidStudioProjects\androidrongflysip\rongflymqtt\src\main\AndroidManifest.xml:96:9-45 Error:
Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:96:9-45
is also present at [:app-debug:] AndroidManifest.xml:29:9-50 value=(@mipmap/ic_launcher_circle).
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:93:5-1486:19 to override.
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
:rongflymqttrocessDevDebugManifest FAILED
Error:Execution failed for task ':rongflymqttrocessDevDebugManifest'.
> Manifest merger failed : Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:96:9-45
is also present at [:app-debug:] AndroidManifest.xml:29:9-50 value=(@mipmap/ic_launcher_circle).
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:93:5-1486:19 to override.
AS的Gradle插件默认会启用Manifest Merger Tool,若Library项目中也定义了与主项目相同的属性(例如默认生成的android:icon和android:theme),则此时会合并失败,并报上面的错误。
解决办法有2种
方法1: 在Manifest.xml的application标签下添加tools:replace="android:icon, android:theme"(多个属性用,隔开,并且记住在manifest根标签上加入xmlns:tools="http://schemas.android.com/tools",否则会找不到namespace哦)
多个冲突这么写
方法2: 在build.gradle根标签上加上useOldManifestMerger true (懒人方法)
再同步Gradle,问题解决。
2.android xml 命名空间错误
这种自动查找的写法,可能会报
No resource identifier found for attribute 'srcCompat' in package 'com.feinno.rongfly'
E:\fetionworkspace\androidrongflysip\rongflymqtt\build\intermediates\exploded-aar\publibrary-debug\res\layout\z_recyclerview.xml
这是因为自动查找会找当前包下的命名空间,会找到主端的包名下。
所以引入的库aar需要直接命名成自己的包名
3.主题设置问题
如果使用了 v7的一些空间,而项目主题没有使用v7的主题则会报
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class android.support.v7.widget.CardView
改成v7的主题就可以了