更改 Firebase 软件包名称 [英] Changing Firebase Package Name

查看:31
本文介绍了更改 Firebase 软件包名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与 Firebase 集成的 Google Sign-In 应用.我最近更改了应用程序包名称以用于发布目的.现在运行抛出这个错误:

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>'

所以我猜 Firebase 无法识别具有新包名称的应用.如何更改 Firebase 包名称.我已经浏览了 Firebase 控制台,但找不到任何更改的包设置.或者有什么好的方法可以实现这一点,而不是再次使用包名和代码创建新项目?任何帮助将不胜感激.

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.

推荐答案

正如 Eurosecom 所评论的,您只需将新的 Android 应用添加到您现有的 Firebase 项目中,并使用新的包名称.执行此操作后,下载更新的 google-services.json 并将其添加到您的应用中.

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.

请注意,Firebase 不使用您的 Java 代码中的实际包名称,而是使用您应用的 build.gradle 文件中的 applicationId:

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"

当您最初在 Android Studio 中创建项目时,包名称和应用程序 ID 将具有相同的值.但是,如果您将代码重构为不同的包,则不会更新应用程序 ID.这解释了为什么应用程序在这样的重构之后会继续工作.但有时可能会令人困惑,这就是为什么我更喜欢让它们保持同步.

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.

这篇关于更改 Firebase 软件包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆