As Eurosecom noted, you can simply add a new Android application to your existing Firebase project with a new package name. After that, download the updated google-services.json and add it to your application.
Note that Firebase does not use the actual package name from your Java code, but uses the applicationId from your application build.gradle file:
defaultConfig { applicationId "com.firebase.hearthchat"
When you initially create a project in Android Studio, the package name and application identifier will have the same value. But if you reorganize your code into another package, the application identifier will not be updated. This explains why the application will continue to work after such refactoring. But sometimes this can be confusing, so I prefer to keep them in sync.
source share