【问题标题】:Unity/Firebase - Project Bundle ID does not match any bundle IDs in your google-services.json filesUnity/Firebase - 项目包 ID 与您的 google-services.json 文件中的任何包 ID 都不匹配
【发布时间】:2017-09-29 02:00:46
【问题描述】:

我正在 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 名称)与 google-services.json 中的 package_names 完全相同。

有什么想法吗?

【问题讨论】:

    标签: firebase unity3d firebase-analytics


    【解决方案1】:

    回答自己有点好笑……

    我偶然发现了问题的原因。我的 VC 运行时出现问题,所以 generate_xml_from_google_services_json.exe 无法从 google-services.json 中提取包名。 (vc90.crt.manifest 无法提取!)

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

    【讨论】:

      【解决方案2】:

      我了解您已通过重新安装 Windows 解决了此问题,但这是我解决此问题的方法,以防其他人遇到此问题:

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

      设置为您在 Firebase 中设置的相同(类似于 com.CompanyName.ProductName)。

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          【解决方案4】:

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

          【讨论】:

            【解决方案5】:

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

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

            完成!有效!!

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2019-06-10
              • 1970-01-01
              • 2018-06-14
              • 1970-01-01
              • 2021-05-22
              • 2017-06-16
              • 2019-11-21
              • 2021-12-07
              相关资源
              最近更新 更多