Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

https://stackoverflow.com/questions/54557479/flutter-and-google-sign-in-plugin-platformexceptionsign-in-failed-com-google

1、add google-service

A:add classpath ‘com.google.gms:google-services:4.2.0’

%app%/android/build.gradle

  
buildscript {  
    repositories {  
        google()  
        jcenter()  
    }  
  
    dependencies {  
        classpath 'com.android.tools.build:gradle:3.2.1'  
        classpath 'com.google.gms:google-services:4.2.0'  
    }  
}  

B:add apply plugin: ‘com.google.gms.google-services’

%app%/android/app/build.gradle

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

2、 get google-service.json

https://firebase.google.com/docs/flutter/setup
https://developers.google.com/android/guides/client-auth

create app

A:create test project

go https://console.firebase.google.com/

B:create application

Where get app name

Open %app%/android/app/build.gradle find applicationId

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

Here is com.example.flutter_sqlite

put com.example.flutter_sqlite in app name, then next.

Download google-service.json

next next…

Copy google.service.json to %app%/android/app/

C:test app in local emu need to fingerprint.

find java jdk\bin\keytool
password use: android

  
C:\Program Files\Java\jdk1.8.0_201\bin>keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore  

copy sha1 to here

Run your flutter app. Now is ok.