簡體   English   中英

Flutter + Firebase + Google 登錄

[英]Flutter + Firebase + Google SigIn

我收到錯誤:

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null

我幾乎完成了我創立的所有事情...

  1. SHA1 和 SHA256(調試模式)
  2. 在 Google 上創建憑據
  3. 在 build.gradle 中更新了谷歌服務插件和 gradle
  4. 在 build.gradle 中添加了 google-service 和 apply de plugin 的類路徑
  5. 在 FireBase 上添加了電子郵件支持
  6. 添加了我的電子郵件,作為配置中的支持電子郵件
  7. 很多很多的“顫動干凈”

它適用於 iOS 模擬器,但不適用於我的 Android 設備。 我使用 Google 和 Flutter 遵循了 SigIn 的“食譜”……但沒有什么能解決我的問題。

當我調用 sigIn() 方法時,VSCode 上的調試模式顯示錯誤:

發生異常。 PlatformException (PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null))

提前感謝您閱讀並給予一些時間。

android/build.gradle:

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

android/app/build.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId "com.xxxx.xxxx"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.multidex:multidex:2.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'

好像你忘了在你的 .gradle 文件中放一些重要的東西。

classpath 'com.google.gms:google-services:4.3.3'必須在 android/build.gradle 中,並且

apply plugin: 'com.google.gms.google-services'必須在 android/app/build.gradle 中

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM