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

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

问题描述

我有一个与Firebase集成了Google登录的应用.我最近为了发布目的更改了应用程序包名称.现在运行时抛出此错误:

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天全站免登陆