我正在使用具有许多不同库依赖项的gradle项目并使用新的清单合并.在我的<application />标签中,我将其设置为:
<application tools:replace="android:icon, android:label, android:theme, android:name"
android:name="com.example.myapp.MyApplcation"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/application_name"
android:logo="@drawable/logo_ab"
android:theme="@style/AppTheme"
>
....
</application>
Run Code Online (Sandbox Code Playgroud)
然而,我收到错误:
/android/MyApp/app/src/main/AndroidManifest.xml:29:9 Error:
Attribute application@icon value=(@drawable/ic_launcher) from AndroidManifest.xml:29:9
is also present at {Library Name} value=(@drawable/app_icon)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:26:5 to override
/android/MyApp/app/src/main/AndroidManifest.xml:30:9 Error:
Attribute application@label value=(@string/application_name) from AndroidManifest.xml:30:9
is also present at {Library Name} value=(@string/app_name)
Suggestion: add 'tools:replace="android:label"' to <application> element at AndroidManifest.xml:26:5 to override
/android/MyApp/app/src/main/AndroidManifest.xml:27:9 Error:
Attribute application@name value=(com.example.myapp.MyApplication) from AndroidManifest.xml:27:9
is also present at {Another Library} …Run Code Online (Sandbox Code Playgroud) 我的 AndroidManifest.xml 文件看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.varianttecnology.uberclone">
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml"). …Run Code Online (Sandbox Code Playgroud) 我正在使用一个使用自己的 android:theme 的库,因此我在构建时收到以下错误:错误:(55, 9) 任务 ':contacit:processDebugManifest' 执行失败。
清单合并失败:来自 AndroidManifest.xml:55:9 的 Attribute application@theme value=(@style/Theme.MainTheme) 也出现在 com.github.florent37:materialviewpager:1.0.3.2:11:18 value=(@style /AppTheme) 建议:将 'tools:replace="android:theme"' 添加到 AndroidManifest.xml:49:5 的元素以覆盖
我修改了我的应用程序的 AndroidManifest.xml 如下:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.main"
android:versionCode="19"
android:versionName="2.5" >
...
<application
android:name="com.example.application.MainApplication"
tools:replace="android:theme"
android:allowBackup="true"
android:icon="@drawable/logo_icon"
android:label="@string/app_name"
android:theme="@style/Theme.MainTheme"
>
...
Run Code Online (Sandbox Code Playgroud)
然而,即使我使用了该tools:replace属性,我仍然从 Manifest 合并中得到同样的错误。任何想法为什么?