Android 合并清单文件失败

Android failed to merge Manifest file

我知道以前有人问过这种类型的问题,但这些答案并没有解决我的问题。 今天我在我的应用程序中添加了一个新版本的 PayU Money,突然它显示错误。我把整个工程转成androidx,同样报错

Manifest merger failed : Attribute application@appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:31:5-163:19 to override.

如果我在 Manifest 文件中添加这个 tools:replace="android:appComponentFactory 它会显示新错误

Manifest merger failed with multiple errors, see logs

在检查 Manifest Merger 时显示

Merging Errors: Error: tools:replace specified at line:31 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 30 Error: Validation failed, exiting app main manifest (this file)

我无法找出错误。这是 build.gradle(app)

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
  }
}
 apply plugin: 'com.android.application'
 apply plugin: 'io.fabric'

 android {
compileSdkVersion 28

defaultConfig {
    applicationId "com.packagename"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode 54
    versionName "5.4"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
    multiDexEnabled true
    ndk.abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'

}
buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
lintOptions {
    checkReleaseBuilds false
    abortOnError false
}
packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}
 repositories {
google()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
maven {
    url "https://oss.sonatype.org/content/repositories/snapshots"
  }
 }

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

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-database:19.1.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'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.volley:volley:1.1.1'

implementation 'com.google.android.gms:play-services-identity:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'com.google.firebase:firebase-perf:19.0.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'

implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
    transitive = true;
}
implementation 'com.google.code.gson:gson:2.8.2'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation 'com.github.bumptech.glide:glide:4.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
implementation 'com.facebook.android:facebook-android-sdk:4.22.0'
implementation 'com.wefika:flowlayout:0.4.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation project(':sdkui')
implementation 'com.android.support:design:28.0.0'
implementation 'com.zopim.android:sdk:1.4.2'

/* Snappydb (cache/db) */

/*For shimmer effect*/
implementation 'com.facebook.shimmer:shimmer:0.4.0'
implementation 'com.snappydb:snappydb-lib:0.5.2'

   }
    apply plugin: 'com.google.gms.google-services'

请帮我解决这个问题

将这两行添加到清单的 <application /> 标签中

   tools:replace="android:appComponentFactory"
   android:appComponentFactory="whateverString"

这对我有帮助。希望这也能帮到你。

您应该尝试一次。您还需要添加这一行。

android:appComponentFactory="whateverString"

对于 GoogleAPIClient 初始化,您应该在 AppCompact 中使用它Activity:

 mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();

删除enableAutoManage() enableAutoManage() 需要 FragmentActivity 或它的某个子类,例如 AppCompatActivity。您不能将 enableAutoManage() 与常规 Activity 一起使用。或者:

  • 将您的代码切换为使用 FragmentActivityAppCompatActivity,或

  • 不打电话enableAutoManage()