记一次 java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs 排查
进入命令行Terminal,输入命令排查
gradlew processDebugManifest --stacktrace
输出如下结果:
Attribute application@label value=(@string/zlong_app_name) from AndroidManifest.xml:62:184-222
is also present at [:facebookres-debug:] AndroidManifest.xml:13:9-41 value=(@string/app_name).
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:62:3-222:17 to override
原来application的android:label有多处地方有定义,而且都用了app_name,而我这边修改了变量名,导致label合并失败.
解决办法:在Mainfest文件头加:
xmlns:tools="http://schemas.android.com/tools"
例:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.anthony.test">
在application头里添加:
tools:replace="android:label"
例:
<application
android:name="com.anthony.test.CustomApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:label" >
重新再运行一次 gradlew processDebugManifest --stacktrace
BUILD SUCCESSFUL in 1s
10 actionable tasks: 3 executed, 7 up-to-date
问题解决!(∩_∩)