清单合并失败:属性application @ appComponentFactory更新Firebase库

Jor*_*dis 8 java gradle firebase build.gradle androidx

我正在尝试在我的项目中添加firebase,但是当我实现'com.google.firebase:firebase-messaging:19.0.0'and时'com.google.firebase:firebase-core:17.0.0'

build.gradle(这是错误)

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
 compileSdkVersion 28
 defaultConfig {
    applicationId "com.example.user.mikripoli"
    minSdkVersion 15
    targetSdkVersion 28
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
 }
 buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
 'proguard-rules.pro'
    }
 }

 dexOptions {
    javaMaxHeapSize "2g"
 }
}

dependencies {
 implementation 'com.roughike:bottom-bar:2.0'
 implementation 'com.android.support:support-v4:28.0.0'
 implementation 'com.android.support:exifinterface:28.0.0'
 implementation 'com.android.support:animated-vector-drawable:28.0.0'
 implementation 'com.flaviofaria:kenburnsview:1.0.7'
 implementation fileTree(include: ['*.jar'], dir: 'libs')
 implementation 'com.android.support:appcompat-v7:28.0.0'
 implementation 'com.android.support.constraint:constraint-layout:1.1.3'
 implementation 'com.android.support:design:28.0.0'
 implementation 'com.github.chrisbanes:PhotoView:2.1.4'
 implementation 'com.google.firebase:firebase-messaging:19.0.0'
 implementation 'com.google.firebase:firebase-core:17.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'
 implementation 'com.android.support:recyclerview-v7:28.0.0'
 implementation 'com.android.support:cardview-v7:28.0.0'
 implementation "com.google.android.gms:play-services-location:17.0.0"
 implementation 'com.google.android.gms:play-services-maps:17.0.0'
 implementation 'com.google.android.gms:play-services-base:17.0.0'
 implementation 'com.github.ahmedshaban1:EasySlider:1.0.0'
 implementation 'com.liangfeizc:SlidePageIndicator:1.1.0@aar'
 implementation 'me.relex:circleindicator:1.2.2@aar'
 implementation 'com.github.bumptech.glide:glide:4.8.0'
 annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
Run Code Online (Sandbox Code Playgroud)

}

另一个gradle文件:

buildscript {

 repositories {
    google()
    jcenter()
 }
 dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    classpath 'com.google.gms:google-services:4.2.0'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
 }

  allprojects {
    repositories {
     google()
     mavenCentral()
     jcenter()
     maven {
        url "https://maven.google.com"
        }
     maven { url "https://jitpack.io" }
   }
  }

  task clean(type: Delete) {
   delete rootProject.buildDir
  }
Run Code Online (Sandbox Code Playgroud)

显示的错误com.android.support:support-v4:28.0.0

无法将使用groupId com.android.support和androidx。*的依赖项组合在一起,但发现IdeMavenCoordinates {myGroupId ='com.android.support',myArtifactId ='cardview-v7',myVersion = '28 .0.0',myPacking ='aar ',myClassifier ='null'}和IdeMavenCoordinates {myGroupId ='androidx.coordinatorlayout',myArtifactId ='coordinatorlayout',myVersion ='1.0.0',myPacking ='aar',myClassifier ='null'}不兼容的依赖项

检查信息:库,工具和库的某些组合不兼容或可能导致错误。一种不兼容的情况是使用不是最新版本的Android支持库版本进行编译(或者特别是低于目标targetSdkVersion的版本)。

另外,当我构建apk时,它显示此错误:

清单合并失败:来自[com.android.support:support-compat:28.0.0]的属性application @ appComponentFactory value =(android.support.v4.app.CoreComponentFactory)来自AndroidManifest.xml:22:18-91 [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value =(androidx.core.app.CoreComponentFactory)。建议:在AndroidManifest.xml:13:5-354:19的元素上添加'tools:replace =“ android:appComponentFactory”'以进行覆盖。

添加工具:replace =“ android:appComponentFactory”无效

Chi*_*ani 13

在新版本中,库从Android支持库迁移到Jetpack(AndroidX)库。

除非您在应用中进行以下更改,否则更新的库将无法工作:

  • 将com.android.tools.build:gradle升级到v3.2.1或更高版本。

  • 将compileSdkVersion升级到28或更高版本。

  • 更新您的应用程序以使用Jetpack(AndroidX);请按照迁移到AndroidX中的说明进行操作

方法1:

将这两个添加到您的gradle.properties文件中,而不进行任何更新

android.useAndroidX=true
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)

方法2

如果Method-1不能解决您的问题,请执行一件事,如果您使用的是Android Studio 3.2或更高版本,请转到Refactor> Migrate to AndroidX ...

  • 这对我有用。我想借此机会表达一下,作为一个不经常使用 Android Studio 的用户,在 Android Studio 中进行开发是多么的痛苦。每次我更新 Studio、SDK、Gradle 等时,我都会冒着花几天时间让一切恢复正常的风险。幸运的是,这次我很快就找到了你的答案。谢谢! (2认同)