错误:清单合并失败:属性application @ appComponentFactory

时间:2019-07-09 12:33:16

标签: android-studio gradle android-gradle build.gradle android-manifest

我在Android Studio中发布了gradle build。当我在项目中添加Admob Activity时,在向项目中添加依赖项时会引发两个错误

  1. ERROR: Manifest merger failed

  2. org.gradle.execution.MultipleBuildFailures:构建完成,发生1次失败 对于第一个问题,它建议像“建议:将'tools:replace =“ android:appComponentFactory”添加到AndroidManifest.xml:10:5-32:19的元素中进行覆盖。 “

即使添加了工具:replace="android:appComponentFactory"到Androidmanifest gradle同步失败

AndroidManifest:

<?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"

2 个答案:

答案 0 :(得分:1)

我有类似的问题。在gradle.properties文件中添加了两行:

android.useAndroidX=true

android.enableJetifier=true

这两行自动解决了我的Google文件与第三方依赖关系之间的依赖关系冲突。

答案 1 :(得分:0)

由于 Google服务已更新,因此将library(tidyverse) ggplot(mpg) + geom_line(mapping = aes(x = displ, y = cty, color = drv), size = 1) + geom_point(data = subset(mpg, drv != '4'), mapping = aes(x = displ, y = cty, color = drv, shape = drv), size = 3) + scale_color_manual(name="Variable", labels = c("4", "f", "r"), values=c("4" = "#DA2128", "f" = "black", "r" = "blue")) + scale_shape_manual(name="Variable", labels = c("f", "r"), values = c("f" = 16, "r" = 17), guide = FALSE) 添加到<TextInput style={{ backgroundColor: '#ffffff', borderRadius: 30, paddingLeft: 8, paddingRight: 8, marginTop: 10 }} placeholder='A placeholder' /> 来找到解决方案:

googlePlayServicesVersion = "16.+"