You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Unity集成Firebase/FB SDK导出Android Studio构建报错:客户端不匹配

Fixing "No matching client found for package name 'com.google.firebase.unity'" in Unity-Android Studio Builds

Let’s break down what’s happening here: That error pops up because the package name specified in your google-services.json file doesn’t match the actual package name your Android project is using. The com.google.firebase.unity value is the default test package name from the Firebase Unity SDK—so your project isn’t correctly passing your app’s real package name through to the build pipeline.

Here’s how to fix this step by step:

  • First, lock in your Unity project’s package name
    Open Unity, go to Edit > Project Settings > Player, switch to the Android tab, and check the Identification > Package Name field. Make sure this is set to your app’s actual package name (e.g., com.yourcompany.yourgame)—not the default test value. This is the foundation of fixing the mismatch.

  • Download a fresh, correct google-services.json
    Head to the Firebase Console, navigate to your project, and go to Project Settings. In the "Apps" section:

    1. If you already have an Android app registered, confirm its package name matches what you set in Unity.
    2. If not, add a new Android app using your Unity package name.
    3. Download the updated google-services.json file, and replace the old one in your Unity project’s Assets/Plugins/Android folder.
  • Clean up Unity’s build cache and reconfigure Firebase

    • Make sure you’re using the latest stable version of the Firebase Unity SDK—outdated versions can cause package name sync issues.
    • If you manually edited any AndroidManifest.xml or Gradle files in Unity, revert those changes. Let Unity handle generating the correct build config automatically.
    • Run File > Build Settings > Clean Build to wipe old build artifacts that might be holding onto the wrong package name.
  • Export to Android Studio correctly
    When exporting from Unity:

    1. Check the "Export Project" option.
    2. Don’t tweak package name settings in the export wizard—let Unity pass through the package name you set in the Player Settings.
    3. Once exported, open the project in Android Studio.
  • Final checks in Android Studio

    • Open app/build.gradle and verify the applicationId matches your app’s package name.
    • Confirm the google-services.json file is in the app directory (Unity should place it there automatically, but double-check).
    • Run File > Sync Project with Gradle Files to ensure all configs are aligned, then try building again.

A quick heads-up if you’re also using Facebook SDK: Make sure your Facebook app dashboard’s package name matches your Unity project’s package name too—mismatches here can cause secondary build conflicts.

内容的提问来源于stack exchange,提问作者cooltogo

火山引擎 最新活动