问题描述
我正在尝试在我的项目中添加Firebase,但是当我实现'com.google.firebase:firebase-messaging:19.0.0'
和'com.google.firebase:firebase-core:17.0.0'
时.
I am trying to add firebase in my project but when I implement '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'
}
另一个gradle文件:
the other gradle file:
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
}
显示有关com.android.support:support-v4:28.0.0
的错误:
检查信息:有一些库或工具的组合, 不兼容的库,或可能导致错误的库.一个这样的 不兼容版本与Android支持版本一起编译 不是最新版本(或特别是版本)的库 低于您的targetSdkVersion.
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
也,当我构建apk时,它会显示此错误:
Also when I build the apk it shows this error:
添加工具:replace ="android:appComponentFactory"无效
adding tools:replace="android:appComponentFactory" doesn't work though
推荐答案
在新版本中,库从Android支持库迁移到Jetpack(AndroidX)库.
With new release, libraries are migrated from the Android Support Libraries to the Jetpack (AndroidX) Libraries.
除非您在应用中进行以下更改,否则更新的库将无法工作:
The updated libraries will not work unless you make the following changes in your app:
-
将com.android.tools.build:升级到v3.2.1或更高版本.
将compileSdkVersion升级到28或更高版本.
更新您的应用程序以使用Jetpack(AndroidX);请按照迁移到AndroidX 中的说明进行操作.
Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
方法1:
将这两个添加到gradle.properties文件中,而无需更新任何内容
add this two in your gradle.properties File, without updating anything
android.useAndroidX=true
android.enableJetifier=true
方法2
如果方法1不能解决您的问题做一件事如果您使用的是Android Studio 3.2或更高版本转到 Refactor>迁移到AndroidX ...
if Method-1 doesn't solve your problemdo one thingif you are using android studio version 3.2 or highergo to Refactor>Migrate to AndroidX...
这篇关于清单合并失败:属性application @ appComponentFactory更新Firebase库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!