错误:程序类型已存在:android.arch.lifecycle.ViewModelStore

时间:2018-12-02 19:20:35

标签: android firebase android-studio firebase-realtime-database

我的Android项目有问题,我无法构建,这是我的错误:

程序类型已经存在:android.arch.lifecycle.ViewModelStore

有人知道如何解决这个问题吗?

当我添加实现'com.firebaseui:firebase-ui-database:2.3.0'时,会发生此错误

这是我的build.gradle`代码

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

 android {
compileSdkVersion 28

defaultConfig {
    applicationId "com.example.merta.cricket"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
implementation 'de.hdodenhof:circleimageview:2.2.0'
api 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:2.3.0'
}

1 个答案:

答案 0 :(得分:0)

您使用的是旧版本,要解决此问题,您还可以更新所有firebase依赖项和google服务插件。

https://firebase.google.com/support/release-notes/android


另一种解决方案,因为您正在使用firebaseui 2.3.0,所以需要将firebase依赖项更新为以下内容:

implementation 'com.google.firebase:firebase-auth:11.2.0'
implementation 'com.google.firebase:firebase-database:11.2.0'
implementation 'com.google.firebase:firebase-storage:11.2.0'

检查此以获取更多信息:

https://github.com/firebase/FirebaseUI-Android/tree/version-2.3.0#compatibility-with-firebase--google-play-services-libraries