Unity/Firebase - 项目包 ID 与您的 google-services.json 文件中的任何包 ID 都不匹配

Unity/Firebase - Project Bundle ID does not match any bundle IDs in your google-services.json files

我正在 Unity 上制作手机游戏,Android 首先。

现在我正在集成 firebase 分析。

在 Firebase 控制台上设置信息并将 google-services.json 文件放入 Unity 项目后,Unity 显示错误消息:

Project Bundle ID com.RetroSpirit.ToiletRush does not match any bundle IDs in your google-services.json files
This will result in an app that will fail to initialize.

Available Bundle IDs:


You need to either:
* Fix your app's bundle ID under "Player Settings --> Bundle Identifier"
or:
* Add another app to your firebase project
  Goto https://firebase.google.com/docs/unity/setup#add_firebase_to_your_app_1
  and add the new configuration file to your project.

UnityEngine.Debug:LogError(Object)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:LogErrorIfEnabled(String)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:FindGoogleServicesFile(SortedDictionary`2, String, LogMessage, LogMessage)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:FindGoogleServicesFile(String, LogMessage, LogMessage)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:UpdateJson(Boolean, LogMessage, LogMessage)
Firebase.Editor.GenerateXmlFromGoogleServicesJson:OnPostprocessAllAssets(String[], String[], String[], String[])
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

这是google-services.json,

的部分
 "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "*:***********:android:****************",
        "android_client_info": {
          "package_name": "com.RetroSpirit.ToiletRush"
        }
      },
      "oauth_client": [
        {
          "client_id": "***********-********************************.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.RetroSpirit.ToiletRush",
            "certificate_hash": "****************************************"
          }

我不知道我应该检查什么。

Project Bundle ID(Build Settings - Other Settings - Identification 中的 Package name)与 google-services.json 中的 package_names 完全相同。

有什么想法吗?

自己回答有点好笑...

我无意中找到了问题的原因。我的 VC 运行时出现问题,因此 generate_xml_from_google_services_json.exe 无法从 google-services.json 中提取包名称。 (vc90.crt.manifest无法提取!)

不幸的是,尽管重新安装了 Visual Studio、VC 运行时和 .net 框架,但我无法修复该运行时错误。最后我重新安装了 Windows 10,问题就消失了......仍然不知道是什么导致了这个错误。

我知道你已经通过重新安装 Windows 解决了这个问题,但这是我解决这个问题的方式,以防其他人遇到这个问题:

确保您已在 Unity 播放器设置中设置包名称(编辑 > 项目设置 > 播放器 > 其他设置 > 标识 > 包名称)。

设置为您在 Firebase 中设置的那个(看起来像 com.CompanyName.ProductName)。

确保您已按照此处所述将 Firebase 资产导入到您的 Unity 项目中 https://firebase.google.com/docs/unity/setup 并且 Firebase 文件夹存在于 Assets > Firebase 中。更改此文件夹的位置似乎会破坏某些东西。

在我们的案例中,我们通过向具有管理员权限的同事请求新的 google-services.json 文件来解决问题。

我的案例是在 Unity 中进行的,为了修复它,我将 firebase 项目中的 google-services.json 添加到资产文件夹中。我之前只有GoogleService-Info.plist。

就我而言,问题出在包名称上。所以我按照以下步骤解决了问题:

  1. 更改包名(com.companyname.appname)[全部小写]
  2. 删除现有的密钥库
  3. 添加新的密钥库并使用 Keytool
  4. 生成指纹
  5. 从 Firebase 控制台删除当前应用程序
  6. 使用正确的包名和生成的指纹添加新应用
  7. 再次下载 google-services.json 并导入到 Unity A​​ssets 文件夹

完成!有效!!