1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Unity(Android) Firebaseのgoogle-services.xmlが生成されない

Last updated at Posted at 2025-02-07

環境

Unity6000.0.34f1
External Dependency Manager for Unity 1.2.183
Firebase App (Core) 12.4.1

はじめに

コマンドラインでAndroidビルドするときに、google-services.xmlが生成されず、アプリ実行時にFirebaseの初期化できない問題があったのでメモ書き程度に残しておきたいと思います。
Assets/External Dependency Manager/Android Resolver/Force Resolveを手動で実行した時には以下の場所に生成されたので、これをスクリプトから実行できるかを調べました。

Assets/Plugins/Android/FirebaseApp.androidlib/res/values/google-services.xml

初期化できないときにでたエラー

Failed to read Firebase options from the app's resources. Either make sure google-services.json is included in your build or specify options explicitly.

手順

1. google-services.jsonをAssets/の中にいれる

そもそも、このファイルが無いと生成されないので一応確認します。

2. 自動Resolveをオフにしておく

Assets/External Dependency Manager/Android Resolver/Settings

image.png

手動でResolveするので、Enable Auto-ResolutionとEnable Resolution On Buildをオフにしておく

3. ビルド前に以下の処理を実行する

private static void ForceResolveGoogleService()
{
    PlayServicesResolver.ResolveSync(true);

    // Firebase の google-services.json から XML 生成
    GenerateXmlFromGoogleServicesJson.ForceJsonUpdate();
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?