Флаттер + Firebase + Google SigIn - PullRequest
0 голосов
/ 02 апреля 2020

Я получаю сообщение об ошибке:

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

Я сделал почти все, что я found ...

  1. SHA1 и SHA256 (режим отладки)
  2. Созданы учетные данные в Google
  3. Обновлен плагин и сервис Google google в build.gradle
  4. Добавлен путь к классу google-сервиса и применить плагин de в build.gradle
  5. Добавлена ​​поддержка электронной почты в FireBase
  6. Добавлена ​​моя электронная почта, в качестве поддержки электронной почты. почта в конфигурациях
  7. Много и много 'flutter clean'

Он работает на симуляторе iOS, но не на моем Android устройстве. Я следовал «рецепту» для SigIn С Google и Flutter ... и ничто не решает мою проблему.

Режим отладки на VSCode показывает ошибку, когда я вызываю метод sigIn ():

Возникло исключение. 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'

1 Ответ

0 голосов
/ 02 апреля 2020

Похоже, вы забыли добавить что-то важное в ваши файлы .gradle.

classpath 'com.google.gms:google-services:4.3.3' должно быть в android / build.gradle, а

apply plugin: 'com.google.gms.google-services' должно быть в android / приложение / build.gradle

...