Categories: Unity

Unity + Android + Firestoreを動かす

UnityでFirestoreを動かす時、iOSはわりとすんなり動いてくれたが、Androidの実機ではうまく動かず苦戦したのでメモ。

エラーはこんな内容
Could not determine the dependencies of task ‘:unityLibrary:compileReleaseAidl’.
> Could not resolve all task dependencies for configuration ‘:unityLibrary:releaseCompileClasspath’.

> Could not find com.google.firebase:firebase-app-unity:6.14.0.      Required by:          project :unityLibrary
> Could not find com.google.firebase:firebase-auth-unity:6.14.0.      Required by:          project :unityLibrary
ときにはこんな内容も出たり。
Could not determine the dependencies of task ‘:unityLibrary:compileDebugAidl’.
> Could not resolve all task dependencies for configuration ‘:unityLibrary:debugCompileClasspath’.
> Could not find com.google.firebase:firebase-analytics-unity:6.14.0.      Required by:          project :unityLibrary
> Could not find com.google.firebase:firebase-app-unity:6.14.0.      Required by:          project :unityLibrary
> Could not find com.google.firebase:firebase-firestore-unity:6.14.0.      Required by:          project :unityLibrary

対策

対策としては、[Assets] > [Import Package] > [Custom Package]  からではなく、Package Managerを使ってインストールすれば問題なくできた。

最初の導入は上記で問題ない(むしろいれないとパッケージマネージャにも表示されないかも?)と思われるが、他のパッケージを入れるときにはパッケージマネージャが必要になる。

Packagesを右クリックして、「パッケージマネージャを表示」
その後、必要なパッケージをInstallする。

原因

import packageをすると、Packagesではなく、Assetsの下に関連ファイルがインストールされてしまうことがあり、そこにインストールされると参照できなくなってしまうようである。

なので、Assetsにインストールされてしまったら問答無用に消してパッケージマネージャでいれなおそう。

GeneratedLocalRepository?みたいなフォルダができてたらインポートがうまくいってない証になる。

まとめ

パッケージマネージャを使って外部ライブラリは管理しよう!

P.S.
Analyticsをドキュメントでは最初に入れているが、Firestore的にはAuthenticationライブラリにも依存しているので合計3ついれないと動かないです!!(Analyticsいれなくても動くけど、リリースするときまでにはどちらにせよ必須で入れとかないといけないやつ)
mogmet

View Comments

  • Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.

  • I don't think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  • I don't think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  • I don't think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  • Your point of view caught my eye and was very interesting. Thanks. I have a question for you.

  • Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?