firebase / quickstart-unity

Firebase Quickstart Samples for Unity
https://firebase.google.com/games
Apache License 2.0
835 stars 433 forks source link

[Bug] google-services.json is not found #1188

Closed IgorGalimski closed 2 years ago

IgorGalimski commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

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

JSON is located in Assets directory and in the project

Screenshot 2021-11-23 at 4 56 44 PM

Also, the issue doesn't appear on the previous version 7.2.0

paulinon commented 2 years ago

Hi @IgorGalimski,

Thanks for reporting this. I see that you provided a screenshot of an Android Studio project hierarchy. Does this mean that you're building for Android?

Additionally, could you confirm if this issue is reproducible when using our quickstart?

IgorGalimski commented 2 years ago

Hi, @paulinon Thanks for the fast reply Yes, this issue appears only for Android I've tried, but all these sample projects don't contain Firebase API

Screenshot 2021-11-23 at 8 14 28 PM
IgorGalimski commented 2 years ago

@paulinon Hi! I've tried to create a new unity project, import FirebaseCrashlytics_8.6.2.unitypackage, and start Firebase. And I see the same error, regardless of google-services.json is in streaming assets Unity's directory I continue using Unity2020.3.20f1 and build for Android. Please, check out the attached file. I removed the json from the project for security reasons

https://www.dropbox.com/s/rshtb0nq5k88k7q/Archive.zip?dl=0

Screenshot 2021-11-24 at 10 47 08 AM

paulinon commented 2 years ago

Hi @IgorGalimski,

After downloading the google-services.json for your app, it should be placed under the Assets folder of your Unity project, not StreamingAssets. Once this is done, a desktop version of your config file will be generated which can be found in Assets > StreamingAssets.

Here's our documentation for reference. I look forward to your results.

IgorGalimski commented 2 years ago

@paulinon Yes, I did this. But anyway I see the exception that google-services.json not found

paulinon commented 2 years ago

Hi @IgorGalimski,

I haven't been able to replicate your issue so far. Here are the steps I performed with the sample project you provided:

  1. Download the google-services.json file and place it in the Assets folder.
  2. Go to Assets > Scenes > SampleScene and press Play (Error message is not present in the Unity console).
  3. Export Unity project to be imported in Android Studio.
  4. Run the app (Error message is not present in the logcat).

Are there any steps that I've missed? Additionally, could you try these steps and see if you're facing the issue?

IgorGalimski commented 2 years ago

Hi @paulinon

I did the same, but still see the issue

Screenshot 2021-11-24 at 12 27 39 PM

Screenshot 2021-11-24 at 12 28 29 PM

paulinon commented 2 years ago

Hi @IgorGalimski,

This behavior seems unusual. Could you confirm if you're facing the same error message in the Unity editor?

Could you also make use of our quickstart and see if the issue persists there as well? You simply need to add your google-services.json file and the appropriate Firebase SDK which can be found here.

IgorGalimski commented 2 years ago

Hi @paulinon I've tried to take a package from dotnet4 folder, but still face the same issue Is it possible to initialize Firebase without this json? I've tried using AppOptions, but it didn't help

paulinon commented 2 years ago

Hi @IgorGalimski,

The google-services.json file is an essential part of your project for you to use Firebase. I have found a thread that talks about this issue, and some developers resolved this by adding a few lines of code in their mainTemplate.gradle file or renaming their Assets/Plugins/Android/Firebase folder to Assets/Plugins/Android/Firebase.androidlib. Could you try if either solution works for you?

IgorGalimski commented 2 years ago

Hi @paulinon I don't have googleservices.xml file

paulinon commented 2 years ago

Hi @IgorGalimski,

I can see that in the thread I provided, and it's possible that the author meant google-services.xml. Do you have this file in your implementation?

Have you tried modifying the mainTemplate.gradle file or renaming the Firebase folder like I previously mentioned? If so, has either of these resolved the issue?

Guidanel commented 2 years ago

One thing that may seem stupid but that actually solved the problem for me was to restart Unity. After restarting inside Assets/Plugins/Android a new folder FirebaseApp.androidlib was created and then the "google-services.json is not found" issue was fixed.

google-oss-bot commented 2 years ago

Hey @IgorGalimski. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@IgorGalimski if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.