Changing Firebase Package Name

Fajar Khan picture Fajar Khan · Oct 23, 2016 · Viewed 33.4k times · Source

I have a app with Google Sign-In integrated with Firebase. I recently changed app package name for release purpose. and now running throwing this error:

Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name '<Package Name>'

So I am guessing Firebase cant recognize app with the new package name. How can I change Firebase package name. I have gone through Firebase console but can't find any changing package settings. Or is there any good way to achieve this instead of creating new project with package name and code again? Any help would be appreciated.

Answer

Frank van Puffelen picture Frank van Puffelen · Oct 23, 2016

As Eurosecom commented, you can just add a new Android app to your existing Firebase project with the new package name. After doing this, download the updated google-services.json and add it to your app.

Note that Firebase does not use the actual package name from your Java code, but uses the applicationId from your app's build.gradle file:

defaultConfig {
    applicationId "com.firebase.hearthchat"

When you initially create a project in Android Studio, the package name and application id will have the same value. But if you refactor your code into a different package, the application id won't be updated. That explains why the app will continue to work after such a refactoring. But it can be confusing at times, which is why I prefer keeping them in sync.