首页 > 解决方案 > Flutter 中的 PlatformException(sign_in_failed, Status{statusCode=CANCELED, resolution=null}, null) 错误

问题描述

我使用了google_sign_in 3.0.5包并按照文档中给出的说明使用了完全相同的代码。

有人可以告诉我在遵循说明时我可能错过了什么,以及我必须做些什么才能让它发挥作用。

标签: dartfluttergoogle-oauth

解决方案


statusCode="Canceled" 的原因是因为我没有更新我的“android/app/build.gradle”文件以使其指向我的密钥库/密钥

android {
    compileSdkVersion 27

    lintOptions {
        disable 'InvalidPackage'
    }

    signingConfigs {
        release {
            storeFile file("path to key/ key") # .keystore or .jsk file extensions
            storePassword 'password'
            keyAlias 'alias'
            keyPassword 'password'
        }
        debug {
            storeFile file("path to key/ key") # .keystore or .jsk file extensions
            storePassword 'password'
            keyAlias 'alias'
            keyPassword 'password'
        }        
    }    

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.applicationName"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.release
        }
        debug {
            signingConfig signingConfigs.debug
        }        
    }
}

推荐阅读