Unity Generation of the Firebase Android resource file google-services.xml from Assets/GoogleService-Info.plist failed
Asked Answered
M

3

9

I would like to setup Firebase in Unity 2020.1.14.

I downloaded the GoogleService-Info.plist into my assets folder and set up a project in the Firebase console.

But as soon as I import the FirebaseAnalytics 7.0 package I'm getting this error:

Generation of the Firebase Android resource file google-services.xml from Assets/GoogleService-Info.plist failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.

"python" "/Users/joerg/Projekte/UnityTest/FirebaseTest2012042/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/GoogleService-Info.plist" -l --plist

Could not find key in plist file: [DATABASE_URL]

How do I set the [DATABASE_URL] in GoogleService-Info.plist?

Thanks Joerg

Mcgraw answered 4/12, 2020 at 17:45 Comment(1)
Just to add to what @iTouch said: 8. You can remove the Realtime Database from Firebase Console if you don't want to get billedMoritz
W
12

This was really frustrating. There is no mention on the original setup tutorial about this issue. I'm assuming more people are going to run in to this problem. So here is the solution:

  1. Go to Firebase Console
  2. Choose your project
  3. Go to "Realtime Database"
  4. Create Realtime Database

After database is created.

  1. Go to "Project Settings"
  2. Download google-services.json and GoogleService-Info.plist
  3. Replace these files in you Unity project. (these files should be inside of the Assets folder, or if you've created a Data folder, then you can find them there.)

In the newly generated files there is a "firebase_url":. Which was missing before. This should now fix this particular error message.

Welkin answered 12/1, 2021 at 16:6 Comment(1)
Thanks for the detailed instructions. Perhaps worth noting: "firebase_url" is in google-services.json but in GoogleService-Info.plist the key is "DATABASE_URL".Ridgepole
M
6

Ok, I found the solution: I just had to setup a database in the Firebase Console and then the url is written to the plist file. This wasn't mentioned in the Google tutorial.

Mcgraw answered 4/12, 2020 at 18:30 Comment(0)
F
3

Simple solution, just add those lines:

<key>DATABASE_URL</key>
<string>https://unexisting.fake.database.firebaseio.com</string>

p.s. I would not recommend enabling database service since it's paid. If for some reason, some plugin will attempt to use it in some way, you will be charged. The only reason I am not using those awesome paid services from Google is that they are only POST PAID without ability to set limit (except you wrote some complicated script yourself which will run in real time and will turn off services once you reach certain limit). There are lot of developers stories who woke up with 5-10k bills due to some error in script.

Fitzpatrick answered 12/5, 2021 at 1:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.