[Flutter/dart] Use google_sign_in in 2 firebase projects(Android)
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.
Recent Posts
See AllWhat want to do I want to create an input form using TextField. For example, if the input content is a monetary amount, I would like to...
What want to do There is a variable that remain unchanged once the initial value is determined. However, it cannot be determined yet when...
What want to do As the title suggests. Place two widgets in one line on the screen One in the center of the screen and the other on the...
Comments