ERROR: Manifest merger failed : Attribute application@appComponentFactory
ERROR: Manifest merger failed : Attribute application@appComponentFactory
我在 Android Studio 中使用 gradle 构建问题。当我在项目中添加 Admob Activity 时,在将依赖项添加到项目时抛出两个错误
ERROR: Manifest merger failed
org.gradle.execution.MultipleBuildFailures:构建完成,但有 1 次失败
对于第一期,它建议像“建议:将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml:10:5-32:19 处的元素以覆盖。
"
即使在添加工具之后:replace="android:appComponentFactory"
到 Android 清单 gradle 同步失败
Android清单:
<?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.ani.admobcheck">
<!-- Include required permissions for Google Mobile Ads to run. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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=".Ads"
android:label="@string/title_activity_ads"></activity>
<!-- Include the AdActivity configChanges and theme. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiM ode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Build.gralde :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ani.admobcheck"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
我收到同步错误:
ERROR: Manifest merger failed : Attribute
application@appComponentFactory value=
(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0]
AndroidManifest.xml:22:18-86 value=
(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to
<application> element at AndroidManifest.xml:10:5-32:19 to override.
我尝试在 AndroidManifest
中添加 tools:replace="android:appComponentFactory"
通过将 googlePlayServicesVersion = "16.+"
添加到 app/build.gradle
找到解决方案,因为 Google 服务 已更新:
buildscript {
ext {
...
googlePlayServicesVersion = "16.+"
}
...
}
我有类似的问题。在 gradle.properties
文件中添加了两行:
android.useAndroidX=true
android.enableJetifier=true
这两行自动解决了我在google的文件和第三方依赖项之间的依赖项冲突。
我在 Android Studio 中使用 gradle 构建问题。当我在项目中添加 Admob Activity 时,在将依赖项添加到项目时抛出两个错误
ERROR: Manifest merger failed
org.gradle.execution.MultipleBuildFailures:构建完成,但有 1 次失败 对于第一期,它建议像“建议:将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml:10:5-32:19 处的元素以覆盖。 "
即使在添加工具之后:replace="android:appComponentFactory"
到 Android 清单 gradle 同步失败
Android清单:
<?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.ani.admobcheck">
<!-- Include required permissions for Google Mobile Ads to run. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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=".Ads"
android:label="@string/title_activity_ads"></activity>
<!-- Include the AdActivity configChanges and theme. -->
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiM ode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Build.gralde :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.ani.admobcheck"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
我收到同步错误:
ERROR: Manifest merger failed : Attribute
application@appComponentFactory value=
(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0]
AndroidManifest.xml:22:18-86 value=
(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to
<application> element at AndroidManifest.xml:10:5-32:19 to override.
我尝试在 AndroidManifest
中添加tools:replace="android:appComponentFactory"
通过将 googlePlayServicesVersion = "16.+"
添加到 app/build.gradle
找到解决方案,因为 Google 服务 已更新:
buildscript {
ext {
...
googlePlayServicesVersion = "16.+"
}
...
}
我有类似的问题。在 gradle.properties
文件中添加了两行:
android.useAndroidX=true
android.enableJetifier=true
这两行自动解决了我在google的文件和第三方依赖项之间的依赖项冲突。