首页 > 解决方案 > 清单合并失败 - android studio 错误

问题描述

我将包的名称更改为“com.xxx.xxx”,Refactor > Rename并将包的名称和应用程序标识符更改为manifestgradle。同步成功,一切正常。根据说明delevopers.google Getting Starteddelevopers.google Intermediate Ads内置在我的应用程序中的广告,之前包含在project structure AdMob中。使用 gradle 时,尝试在物理级别上运行应用程序让我付出了代价。

Manifest merge error: Attribute application @ appComponentFactory value = (android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml: 22: 18-91
also present in [androidx.core: core: 1.0.0] AndroidManifest.xml: 22: 18-86 value = (androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools: replace = "android: appComponentFactory"' to the <application> element in AndroidManifest.xml: 8: 5-27: 19 to override.

如果您在 gradle 属性中做广告android.useAndroidX = trueandroid.enableJetifier = true那么一切都会变得更糟,因为我的MainActivity.javaextendit 是AppCompatActivity,它不与上述gradle属性一起使用(android.useAndroidX = true)

标签: androidandroid-studioadmobandroid-manifestandroidx

解决方案


这是因为在 gradle 中,您还必须将其更改为 androidX 并检查您的依赖关系

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.0.0'

    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'com.google.android.gms:play-services-ads:18.1.1'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}




android {
    compileSdkVersion 28

defaultConfig {
        applicationId "com.example1.*appname*"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 3
        versionName "3.0"
        **testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"**//check this is their or not
    }

有时我们忘记定义 testInstrument runner


推荐阅读