Google and Firebase manuals are not ideal and sometimes even contradicting. So I met some obstacles trying to implement simple sign in process with Google via the Firebase at the Android app. Some of problems are described here.
Finally, nuclear solution worked for me, so I needed to recreate the Firebase project. Here is the consequence of steps that worked:
- Delete and recreate values at the local computer storage
- Delete SHA-1 key at the local keystore and generate new debug SHA-1 via new build.
- Rename the package via refactoring, e. g. from com.example.myproject to com.example.mynewproject. Clear some leftovers remaining after refactoring by searching old name "com.example.myproject" in the project files and manually renaming them. Package name is the same essential as SHA-1 for Google Cloud and Firebase consoles. So these consoles don't allow to use old SHA-1 keys from the old deleted projects. Neither might they allow to use old project names which are unique for the particular app I guess.
- Delete and recreate projects in the cloud
- Delete cloud projects:
- Delete Firebase project and verify in the Firebase console that there no active projects yet.
- Delete Google Cloud project. Verify at the consequent console that there are no active projects listed. Often Google Cloud is deleted automatically after deleting the Firebase project.
- Recreate cloud projects:
- At the Firebase console, create new project.
- At the Google Cloud Console, nothing is needed to be done. Despite that Firebase manual cross references to Google manual directing us to create new Google Cloud app, we don't need to do this. Because later it will be created automatically by Firebase.
- In the created Firebase project create an Android app, pass there new package name and new SHA-1 key that were created at the previous steps.
- In the Google Cloud Console, see that Firebase automatically created Cloud project with the same name as was passed to Firebase. Then confirm that two of OAuth 2.0 Client IDs were automatically created there by Firebase.
- Final changes on local:
- From the Firebase console, download new google-services.json file and delete old file at the local machine which similarly named in the app folder.
- In the Google Cloud Console, copy client id labelled "Web application" (not "Android") and hardcode it in the local app code:
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(R.string.default_web_client_id_hardcoded))