我在编译项目时面向下方使用
以下是错误日志
Error:Execution failed for task ':sampleproject:processDebugAndroidTestManifest'.
> java.lang.IllegalArgumentException: Multiple entries with same key: android:allowBackup=REPLACE and android1:allowBackup=REPLACE
的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.sample.mini" >
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-sdk tools:overrideLibrary="com.sample.toolkit.payment"/>
<application
android:allowBackup="false"
android:icon="@mipmap/icn_app"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="false"
android:theme="@style/MaterialTheme"
tools:replace="android:label, theme, allowBackup, android:icon,android:supportsRtl">
<activity
android:name="com.sample.SwiftActivity"
android:screenOrientation="portrait"
android:theme="@style/MaterialTheme" />
<activity
android:name="com.activities.TermsAndConditionActivity"
android:screenOrientation="portrait"
android:theme="@style/MaterialTheme" />
</application>
</manifest>
答案 0 :(得分:9)
尝试从tools:replace
列表中删除空格。
tools:replace="android:label,theme,allowBackup,android:icon,android:supportsRtl"
这为我修复了构建错误,但我还是想弄清楚为什么空格后的条目会被忽略
答案 1 :(得分:0)
尝试将android:
添加到allowBackup
列表中tools:replace
的前面
tools:replace="android:label,theme,android:allowBackup,android:icon,android:supportsRtl"
答案 2 :(得分:0)
我收到相同的失败通知:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Multiple entries with same key: android:supportsRtl=REPLACE and android:supportsRtl=REPLACE
android AndroidManifest.XML是:
<application
android:name=".MyApplication"
android:allowBackup="false"
android:supportsRtl="false"
tools:replace="android:allowBackup,android:supportsRtl"
android:icon="@drawable/icon"
android:networkSecurityConfig="@xml/network_security_config"
android:label="@string/app_name"
android:largeHeap="true"
android:manageSpaceActivity=".ManageSpaceActivity">
最后,我通过在“ android:allowBackup”和“ android:supportsRtl”之间添加一个空格来解决该问题
tools:replace="android:allowBackup, android:supportsRtl"
我不知道为什么,但是我认为这可能是Android Studio的错误,希望它会为您提供解决问题的建议。
答案 3 :(得分:0)
在我的情况下,这种情况正在发生,因为我添加了PayuMoney付款网关的PlugnPlay依赖关系。删除后,我可以构建我的应用程序。
答案 4 :(得分:0)
尝试删除每个项目中的android:
tools:replace="android:label, theme, allowBackup, android:icon,android:supportsRtl">
答案 5 :(得分:-2)
Try my plugin to fix it.
Seal - A gradle plugin to do precheck of Android Manifest.
中传递参数1.Compile&amp;应用Seal插件:
// project's build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'me.xx2bab.gradle:seal-manifest-precheck-plugin:1.0.0'
}
}
...
// app's build.gradle
apply plugin: 'seal'
<强> 2.Configurations:强>
def projectRoot = project.getRootProject().rootDir.absolutePath
// Folders may include AndroidManifest.xml files
// 1. For gradle plugin 2.3.0 or higher, build-cache is default choice,
// 2. But we should make sure snapshot-libs will be checked too.
// 3. Free to add your folders for more customization
def manifestPath = [
// for AAR of Release
// see note below
projectRoot + '/build-cache',
// for AAR of SNAPSHOT
projectRoot + '/app/build/intermediates/exploded-aar'
]
def removeAttrs = [
'android:debuggable'
]
def replaceValues = [
'android:allowBackup'
]
seal {
enabled = true
manifests = manifestPath
appAttrs {
enabled = true
attrsShouldRemove = removeAttrs
}
appReplaceValues {
enabled = true
valuesShouldRemove = replaceValues
}
}
3.注意:如果启用了build-cache
,则Seal建议将自定义构建缓存文件夹置于项目文件夹中。
//gradle.properties
android.buildCacheDir=./build-cache
...