Firebase身份验证和数据库链接

时间:2018-08-22 15:25:48

标签: android gradle firebase-realtime-database android-gradle firebase-authentication

在android studio 3.1.3中,用于链接Firebase身份验证“ 实现'com.google.firebase:firebase-auth:11.6.0'”和 链接Firebase数据库“ 实现'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版本。

3 个答案:

答案 0 :(得分:0)

只需更新它们

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

和您的Google gms更新为

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

答案 1 :(得分:0)

此处是查看最新Firebase SDK版本的链接。我认为使最新的版本能够协同工作是一个合理的假设。

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

答案 2 :(得分:0)

如果这个问题是Linux特有的,我不知道。但是无论如何,最终我不得不降级依赖项以使其正常工作。

模块应用(依赖项)

compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'

项目

    dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:4.0.1'