为建立中文知识库加块砖 ——中科大胡不归
问题描述
项目合并了第三方的aar,经常遇到如下报错:
Manifest merger failed with multiple errors, see logs
解决办法
在Android Studio的Terminal中输入下面的命令可以打印更详细的日志:
gradlew processDebugManifest -stacktrace
执行结果类似如下:
C:\Users\alex\Desktop\***\app\src\main\AndroidManifest.xml:27:13-60 Error:
Attribute provider#androidx.core.content.FileProvider@authorities value=(***.provider) from [AwePhotos_0.1.11.aar] AndroidManifest.xml:27:13-60
is also present at [com.pgyersdk:sdk:3.0.10] AndroidManifest.xml:20:13-64 value=(***.fileProvider).
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:25:9-33:20 to override.
C:\Users\alex\Desktop\***\app\src\main\AndroidManifest.xml:32:17-51 Error:
Attribute meta-data#android.support.FILE_PROVIDER_PATHS@resource value=(@xml/file_paths) from [AwePhotos_0.1.11.aar] AndroidManifest.xml:32:17-51
is also present at [com.pgyersdk:sdk:3.0.10] AndroidManifest.xml:25:17-55 value=(@xml/provider_paths).
Suggestion: add 'tools:replace="android:resource"' to <meta-data> element at AndroidManifest.xml to override.
剩下的按照Suggestion去排除错误。
备注
需要用"tools:replace"添加的地方应该在需要被替换的属性的同一级。
比如提示替换"android:authorities",是需要将如下语句:
tools:replace="android:authorities"
添加在"android:authorities"所在的一级,如下:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true"
tools:replace="android:authorities">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
tools:replace="android:resource"
android:resource="@xml/file_paths" />
</provider>
。
网友评论