Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to read Firebase options from the app's resources #761

Open
xjjon opened this issue Jun 13, 2023 · 14 comments
Open

Failed to read Firebase options from the app's resources #761

xjjon opened this issue Jun 13, 2023 · 14 comments

Comments

@xjjon
Copy link

xjjon commented Jun 13, 2023

[READ] For Firebase Unity SDK issues, please report to Firebase Unity open-source

Once you've read this section and determined that your issue is appropriate for this repository, please delete this section.

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2021.3 and 2022.3
  • Firebase Unity SDK version: 11.1
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Analytics, Crashlytics
  • Other Firebase Components in use: N/A
  • Additional SDKs you are using: N/A
  • Platform you are using the Unity editor on: Windows
  • Platform you are targeting: Android
  • Scripting Runtime: Mono

[REQUIRED] Please describe the issue here:

(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

Error firebase 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.

Firebase does not generate the Plugins/Android/FirebaseApp.androidlib & FirebaseCrashlytics.androidlib folders so there is no values/google-services.xml file.

I copied these files from an older install of firebase (2020) and it worked.

Steps to reproduce:

Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)?
What's the issue repro rate? (eg 100%, 1/5 etc)

100% repo rate.
Fresh 2021 and 2022 LTS projects.

Add google-services.json and GoogleService-Info.plist to root /Assets/ folder

Import Analytics and Crashlytics unitypackage (downloaded latest from firebase site)

Resolve dependencies in dependency resolver.

Add the sample init code and crashlytics test code (from docs)

Build .apk

Check Logcat

2023/06/13 21:26:30.557 19928 20114 Error firebase 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.

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

@xjjon xjjon added the new New issue. label Jun 13, 2023
@xjjon
Copy link
Author

xjjon commented Jun 13, 2023

I believe it is related to this:

Sometimes it works and loads properly (which will allow the required google-esrvices.xml files to be generated).
But I'm not sure why this is happening.

Assembly 'Assets/Firebase/Editor/Firebase.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Assembly 'Assets/Firebase/Editor/Firebase.Crashlytics.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

@chkuang-g chkuang-g transferred this issue from firebase/quickstart-unity Jun 13, 2023
@chkuang-g chkuang-g added api: analytics needs-attention Need Googler's attention type: question and removed new New issue. labels Jun 13, 2023
@xjjon
Copy link
Author

xjjon commented Jun 13, 2023

Seems that installing iOS build support to my 2022.3 install allowed me to build and confirm that analytics/crashlytics worked.
However it didn't generate the required google-services.xml file. See here: googlesamples/unity-jar-resolver#412 (comment)

In 2021.3 I was able to get those generated and copied it to my 2022.3 project so it worked as a "fix".

@a-maurice
Copy link
Collaborator

Hi @xjjon

Odd that it is still failing to generate the xml file. I assume there are no errors or anything useful in the logs? The script/executable that should do that is in Assets/Firebase/Editor, generate_xml_from_google_services_json.exe (or .py). If you try running that directly, does that give any helpful info?

@a-maurice a-maurice added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Jun 14, 2023
@xjjon
Copy link
Author

xjjon commented Jun 14, 2023

hi @a-maurice

I tried to run the .exe (didn't seem to do anything)

Tried to run the python script next. Initially it gave errors:

python Firebase/Editor/generate_xml_from_google_services_json.py
Traceback (most recent call last):
  File "E:\MyProject\Assets\Firebase\Editor\generate_xml_from_google_services_json.py", line 498, in <module>
    sys.exit(main())
             ^^^^^^
  File "E:\MyProject\Assets\Firebase\Editor\generate_xml_from_google_services_json.py", line 355, in main
    with open(input_filename, 'r') as ifile:
         ^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'app/google-services.json'

Wasn't sure the arguments to run it with so i just moved my google-services.json to the default app/google-services.json location.

Ran it again from root /Asset/ folder and it produced the and res/values/google-services.json but in the wrong output directory. (it puts it in the directory i run it from)

The values generated by the .py are correct though (I compared it to the values in downloaded .json)

--

Another issue I noticed is the crashlytics_build_id.xml doesn't get updated. I wasn't able to find out where this is updated from.

@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jun 14, 2023
@a-maurice
Copy link
Collaborator

Alright, that seems to indicate that the problem is on the dll side, and not on the generating the xml from the json at least.

Another thing to try would be on the two Editor dlls (located in Assets/Firebase/Editor), in the Inspector pane turning off "Validate References". Installing the iOS build support should've also resolved that, but maybe something else is going wrong, and that can help?

@xjjon
Copy link
Author

xjjon commented Jun 15, 2023

I tried that first (before installing iOS build support module) and disabling validation removed the errors in the editor. But it would cause compile errors when building an .apk

There's a similar comment here on this thread: googlesamples/unity-jar-resolver#412 (comment)

@AlmostMatt
Copy link
Contributor

@xjjon, Let me know if the following an accurate summary.

  1. When trying to build for Android, you encountered this error:
    Error firebase 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.

  2. You observed that the following folder does not exist:
    /Plugins/Android/FirebaseApp.androidlib
    And so this file also does not exist
    /Plugins/Android/FirebaseApp.androidlib/res/values/google-services.xml

  3. As a workaround, you tried copying that folder and those files from an older version of your project (using Unity 2021?) to the new project. With this workaround you are able to build successfully.

  4. In order to try to get google-services.xml generation to work, you also tried:

  • disabling 'Validate References' on the Editor dlls in Assets/Firebase/Editor (This resulted in compilation errors)
  • installing iOS build support module
  1. You have tried manually running generate_xml_from_google_services_json.py, and you observe that it was able to read your google-services json file and generated a valid xml file. (You used default input and output directories for the script)

A few questions

  • Is all of that accurate?
  • When you build for Android, do you see any console logs like "Config File Generation Failed" or "Generation of the Firebase Android resource file ... failed" with additional information about the failure?
  • Did installing iOS build support module cause xml generation to work?

@AlmostMatt AlmostMatt added needs-info Need information for the developer and removed needs-attention Need Googler's attention labels Jun 26, 2023
@AnassCarreau
Copy link

Hi, I have the same problem

@xjjon
Copy link
Author

xjjon commented Jun 27, 2023

@xjjon, Let me know if the following an accurate summary.

1. When trying to build for Android, you encountered this error:
   `Error firebase 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.`

2. You observed that the following folder does not exist:
   /Plugins/Android/FirebaseApp.androidlib
   And so this file also does not exist
   /Plugins/Android/FirebaseApp.androidlib/res/values/google-services.xml

3. As a workaround, you tried copying that folder and those files from an older version of your project (using Unity 2021?) to the new project. With this workaround you are able to build successfully.

4. In order to try to get google-services.xml generation to work, you also tried:


* disabling 'Validate References' on the Editor dlls in Assets/Firebase/Editor (This resulted in compilation errors)

* installing iOS build support module


5. You have tried manually running generate_xml_from_google_services_json.py, and you observe that it was able to read your google-services json file and generated a valid xml file. (You used default input and output directories for the script)

A few questions

* Is all of that accurate?

* When you build for Android, do you see any console logs like "Config File Generation Failed" or "Generation of the Firebase Android resource file ... failed" with additional information about the failure?

* Did installing iOS build support module cause xml generation to work?

Yes that is correct. Copying the google-services.xml and file structure from an older project (i.e. 2021, 2020, etc) worked as long as Validate References was disabled. Validate references fixed the in-editor errors but would cause compilation errors at build time.

After installing iOS build support it worked as expected. I see crashlytics_build_id.xml updating with each build. Also with the debug logging on I see the log messages updating the android manifests with each code reload

Patch Android Manifest with new bundle ID -> myBundleId
PlayServicesResolver initialization succeeded.

So to summarize, installing iOS build support seems to resolve the issue. In previous installs of Unity I only keep Android build support installed on windows environment though. We use a different environment (mac) to build iOS and that one only has iOS build support installed. The workaround we have now is installing both android and iOS on all our environments.

@xjjon xjjon closed this as completed Jun 27, 2023
@xjjon
Copy link
Author

xjjon commented Jun 27, 2023

Didn't mean to close the issue. Re-opening

@xjjon xjjon reopened this Jun 27, 2023
@google-oss-bot google-oss-bot added needs-attention Need Googler's attention and removed needs-info Need information for the developer labels Jun 27, 2023
@Orhonbey
Copy link

Orhonbey commented Jul 4, 2023

Hello, I have the same problem, and not fixed.
@xjjon thank you.
Unity version 2022.3.1f and 2022.3.4f

@fuwapaca
Copy link

I have the same problem, after adding ios build support , the firebase script seems to able to generate FirebaseApp.androidlib folder and the xml file inside, and the problem resolved.

@nanduzz
Copy link

nanduzz commented Oct 3, 2023

I have the same problem, and I agree that is related to this:

I believe it is related to this:

Sometimes it works and loads properly (which will allow the required google-esrvices.xml files to be generated). But I'm not sure why this is happening.

Assembly 'Assets/Firebase/Editor/Firebase.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Assembly 'Assets/Firebase/Editor/Firebase.Crashlytics.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

but after geting this tip, I went on the Firebase.Editor and disabled the validation for this file, if you click on it, there is a checkbox "Validate References" that I've unchecked. After applying the menu "Window>Firebase" started to show ( wasn't showing previously ) and the folder /Assets/Plugins/Android/FirebaseApp.androidlib was created automaticaly with all the resources inside, including the google-services.xml

BTW, I'm using:
Unity 2022.3.7f1
Firebase 11.5.0

@lukamix
Copy link

lukamix commented Jun 11, 2024

I have the same problem, and I agree that is related to this:

I believe it is related to this:
Sometimes it works and loads properly (which will allow the required google-esrvices.xml files to be generated). But I'm not sure why this is happening.

Assembly 'Assets/Firebase/Editor/Firebase.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Assembly 'Assets/Firebase/Editor/Firebase.Crashlytics.Editor.dll' will not be loaded due to errors:
Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.

but after geting this tip, I went on the Firebase.Editor and disabled the validation for this file, if you click on it, there is a checkbox "Validate References" that I've unchecked. After applying the menu "Window>Firebase" started to show ( wasn't showing previously ) and the folder /Assets/Plugins/Android/FirebaseApp.androidlib was created automaticaly with all the resources inside, including the google-services.xml

BTW, I'm using: Unity 2022.3.7f1 Firebase 11.5.0

I have same issue and this work with me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants