[Flutter/dart] Use google_sign_in in 2 firebase projects(Android)
- M.R
- Nov 18, 2021
- 1 min read
Overview
If you're using firebase, you want to separate your development environment from your production environment.
In this process in Flutter, I stumbled on Android's google_sign_in
Detail
Create two firebase projects, one for development and one for production, and start them in debug mode. Then, I get the following error in google_sign_in.
Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null)
This is because in google_sing_in (in firebase?) the combination of the application id (like com. ***) and the SHA1 fingerprint cannot be duplicated.
(See here for details. However, the error did not go away even with the measures described here.)
Solution
As a workaround, change the application id when in debug mode.
Write as follows in /android/app/build.gradle.
defaultConfig {
applicationId "com.xxx.yyy"
・・・
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
・・・
}
Also, modify /android/app/src/debug/google-service.json as follows.
"client": [
{
"client_info": {
・・・
"android_client_info": {
"package_name": "com.xxx.yyy.debug"
}
},
Without this modification, you get the following error.
Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.xxx.yyy
After taking the above measures, I was able to sign in with google safely.
Comments