首页 > 解决方案 > Firebase 身份验证和数据库链接

问题描述

在 android studio 3.1.3 中,用于链接 firebase 身份验证“ implementation 'com.google.firebase:firebase-auth:11.6.0' ” 并用于链接 firebase database “ implementation 'com.google.firebase:firebase-database:11.8.0 ' " 是应用级别 gradle 中提供的默认依赖项。

classpath 'com.google.gms:google-services:3.0.0'是添加的依赖项

apply plugin: 'com.android.application'

android {
  compileSdkVersion 27
  defaultConfig {
    applicationId "com.project.arsalan.adda"
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
}

repositories {
  maven {
    url "https://maven.google.com/"
  }
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'com.android.support:appcompat-v7:27.1.1'
  implementation 'com.android.support:design:27.1.1'
  implementation 'com.android.support.constraint:constraint-layout:1.1.2'
  implementation 'com.android.support:support-v4:27.1.1'
  implementation 'com.google.firebase:firebase-core:9.8.0'
  implementation 'com.google.firebase:firebase-auth:9.8.0'
  implementation 'com.google.firebase:firebase-database:9.8.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:cardview-v7:27.1.1'
  implementation 'de.hdodenhof:circleimageview:2.1.0'
  implementation 'com.yarolegovich:lovely-dialog:1.1.0'
  implementation 'com.android.support:recyclerview-v7:27.1.1'
  implementation 'com.android.support:percent:25.0.1'

}

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

在项目级别的gradle中。

我正在使用 gradle 3.1.2

不同级别的firebase导致我出错。请提供可与我的 gradle 构建一起使用的通用级别的 firebase 版本。

标签: androidgradlefirebase-realtime-databaseandroid-gradle-pluginfirebase-authentication

解决方案


只需更新它们

implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'

和你的谷歌 gms 更新

dependencies {
    classpath 'com.google.gms:google-services:4.0.1'
    // ...
}

推荐阅读