我刚刚创建了一个空的android项目,同时包含了该项目所需的依赖项,只有在添加com.google.firebase
或com.google.android.gms
时,我才会看到错误,它将在下面生成错误。
/Users/macbookair/Desktop/ANDROID/APPTEST/app/src/main/AndroidManifest.xml:22:18-91
错误:属性application @ appComponentFactory
值=(android.support.v4.app.CoreComponentFactory)来自
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91也位于
[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
值=(androidx.core.app.CoreComponentFactory)。意见建议:添加
'tools:replace =“ android:appComponentFactory”'元素
在AndroidManifest.xml:5:5-21:19进行覆盖。
请任何人帮助我,我已经尝试了很长时间以解决此错误。
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.fexample.android.appz"
minSdkVersion 18
targetSdkVersion 28
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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'
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 'org.apache.httpcomponents:httpcore:4.4.10'
implementation 'com.squareup.okhttp3:okhttp:3.13.1'
implementation 'com.facebook.android:facebook-login:4.41.0'
//If I uncomment the below line it will trigger error
//implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
//implementation 'com.google.android.gms:play-services-auth:17.0.0'
//implementation 'com.google.firebase:firebase-core:17.2.0'
//implementation 'com.google.firebase:firebase-messaging:20.0.0'
}
android {
useLibrary 'org.apache.http.legacy'
}
apply plugin: 'com.google.gms.google-services'
android { sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/public'] } } }
从下面的屏幕截图中,该
implementation 'com.android.support:appcompat-v7:28.0.0'
也有一个错误,但是当我成功构建apk时,我认为这不好。使用groupId com.android.support和androidx。*的依赖项不能
被合并但被发现
IdeMavenCoordinates {myGroupId ='com.android.support',
myArtifactId ='support-fragment',myVersion = '28 .0.0',myPacking ='aar',
myClassifier ='null'}和
IdeMavenCoordinates {myGroupId ='androidx.swiperefreshlayout',
myArtifactId ='swiperefreshlayout',myVersion ='1.0.0',myPacking ='aar',
myClassifier ='null'}
最佳答案
我建议您尝试以下方法之一:
1)迁移整个项目以使用androidx
库,您可以在菜单栏中的“重构”>“迁移到AndroidX”下进行操作。
2)将com.google.firebase
和com.google.android.gms
的版本从17.x.x降级到较低的版本