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. #596

Closed
tkminh opened this issue Feb 28, 2020 · 11 comments
Closed

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

tkminh opened this issue Feb 28, 2020 · 11 comments
Labels
needs-info Need information for the developer type: question

Comments

@tkminh
Copy link

tkminh commented Feb 28, 2020

Please fill in the following fields:

Unity editor version: 2019.3.06f
Firebase Unity SDK version: 6.6.0
Firebase plugins in use (Auth, Database, etc.):https://assetstore.unity.com/packages/tools/network/cross-platform-leaderboard-151816?_ga=2.216116694.174958842.1582891597-1598787340.1576925179
Additional SDKs you are using (Facebook, AdMob, etc.):
Platform you are using the Unity editor on (Mac, Windows, or Linux): Windows 8.1
Platform you are targeting (iOS, Android, and/or desktop): Android
Scripting Runtime (Mono, and/or IL2CPP): Mono

Please describe the issue here:

I'm working on unity project that will post SCORE data to Firebase realtime database (https://assetstore.unity.com/packages/tools/network/cross-platform-leaderboard-151816), and it works when I test on UnityEditor, but not on real mobile android device. :(

Here is the logcat:

02-23 11:34:41.889 13194-13271/com.devzuky.dumpy E/Unity: 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.
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String) (at Z:\tmp\tmp.YjzkX82xZ8\firebase\app\client\unity\src\Unity\FirebaseLogger.cs:95)
Firebase.LogUtil:LogMessage(LogLevel, String) (at Z:\tmp\tmp.BahqeQHBdV\firebase\app\client\unity\proxy\LogUtil.cs:68)
Firebase.LogUtil:LogMessageFromCallback(LogLevel, String) (at Z:\tmp\tmp.BahqeQHBdV\firebase\app\client\unity\proxy\LogUtil.cs:76)

Running on desktop I found Assets\StreamingAssets\google-services-desktop.json -> and if i remove this file, and try to run, it will show the same errors as above.
So I think the android build didn't have the file google-services.json ? How can I added to the build and which location ?

@tkminh tkminh added the new New issue. label Feb 28, 2020
@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@patm1987
Copy link

Hi @tkminh,

If this is a bug, I will need you to to try to reproduce this in one of the Unity Quick Start's if possible so we can get a good starting point to work from.

Additionally, upgrading to the latest plugin (version 6.11.0) might help as well. In particular, I see a potentially related fix in 6.8.0.

Since you do see a google-services-desktop.json, I assume that you did download the google-services.json file needed for Android. You can drop it anywhere in your Assets/ directory, although I like to place it under Assets/Data.

Finally, since you do list Auth as one of the SDKs you're using, did you enable the authentication providers you plan on using? You can follow the instructions in the video on this page.

If any of those above steps work, let us know! Otherwise, repro steps in the quickstart will help us a ton!

Thanks,
--Patrick

@patm1987 patm1987 added needs-info Need information for the developer and removed new New issue. labels Feb 28, 2020
@tkminh
Copy link
Author

tkminh commented Feb 29, 2020

Hi @patm1987 ,

I solved it by adding below in the mainTemplate.gradle

sourceSets { main { res.srcDirs += '<fullpath>\\Assets\\Plugins\\Android\\Firebase\\res\\values\\googleservices.xml' } }

Many thanks.
Minh

@Thaina
Copy link
Contributor

Thaina commented Mar 18, 2020

What happen or what changed that we need to add that sourceSets { main { res.srcDirs += something something? What is that thing and why we just need it now to build firebase?

@srkoga
Copy link

srkoga commented Mar 23, 2020

I have the same problem, even adding sourceSets and the google-services.json file, it didn't work, I use UNITY 2019.3.6f1, firebase sdk 6.12.0, windows 10, to create android. I've tested it on other versions of unity and the same error happens.

"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."

I followed the video tutorial https://www.youtube.com/watch?v=A6du3DUTIPI&feature=youtu.be but it doesn't work.

Any other solution?

sorry for the english ... I don't know much ... :)

After testing a little more, I realized that Unity was not generating the googleservices xml.

Searching I found a site that converts google-services.json to XML values.
  https://dandar3.github.io/android/google-services-json-to-xml.html

I created an xml file, and saved it to the folder, Assets \ Plugins \ Android \ Firebase \ res \ values

I managed to generate the apk and run it without a problem after this change, but there is still an error when I open it
Windows / Firebase / Documentation
"Project Bundle ID com.FirebaseTestProject does not match any bundle IDs in your google-services.json files. This will result in an app that will fail to initialize."

I believe that the error is in the files generate_xml_from_google_services_json exe and py, I'm not sure about that or it could be a Unity error.

Hope this helps.

@tkminh
Copy link
Author

tkminh commented Mar 25, 2020

What happen or what changed that we need to add that sourceSets { main { res.srcDirs += something something? What is that thing and why we just need it now to build firebase?

Because the google file is missing when we build to APK, you can try to debug ABK Profiler to see it. So we just need to find a way to add in our APK.

@tkminh
Copy link
Author

tkminh commented Mar 25, 2020

I have the same problem, even adding sourceSets and the google-services.json file, it didn't work, I use UNITY 2019.3.6f1, firebase sdk 6.12.0, windows 10, to create android. I've tested it on other versions of unity and the same error happens.

"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."

I followed the video tutorial https://www.youtube.com/watch?v=A6du3DUTIPI&feature=youtu.be but it doesn't work.

Any other solution?

sorry for the english ... I don't know much ... :)

After testing a little more, I realized that Unity was not generating the googleservices xml.

Searching I found a site that converts google-services.json to XML values.
  https://dandar3.github.io/android/google-services-json-to-xml.html

I created an xml file, and saved it to the folder, Assets \ Plugins \ Android \ Firebase \ res \ values

I managed to generate the apk and run it without a problem after this change, but there is still an error when I open it
Windows / Firebase / Documentation
"Project Bundle ID com.FirebaseTestProject does not match any bundle IDs in your google-services.json files. This will result in an app that will fail to initialize."

I believe that the error is in the files generate_xml_from_google_services_json exe and py, I'm not sure about that or it could be a Unity error.

Hope this helps.

Please try to add the script in the mainTemplate.gradle
I've tested and it really work.

// Android Resolver Exclusions End
android {
compileSdkVersion APIVERSION
buildToolsVersion 'BUILDTOOLS'

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    minSdkVersion **MINSDKVERSION**
    targetSdkVersion **TARGETSDKVERSION**
    ndk {
        abiFilters **ABIFILTERS**
    }
    versionCode **VERSIONCODE**
    versionName '**VERSIONNAME**'
    consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}

lintOptions {
    abortOnError false
}

sourceSets {
    main {
        res.srcDirs += 'C:\\Working\\game\\dumpy\\Assets\\Plugins\\Android\\Firebase\\res\\values\\googleservices.xml'
        
    }
}

aaptOptions {
    noCompress = ['.unity3d', '.ress', '.resource', '.obb', 'google-services.json']
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**

}REPOSITORIES****SOURCE_BUILD_SETUP
EXTERNAL_SOURCES

@Thaina
Copy link
Contributor

Thaina commented Mar 25, 2020

@tkminh I see, so the point is, we must do everything to add \res\ folder in project back into sourceSets with gradle

But I wonder why we never need to do that and unity will always build correctly. it seem this 2020 change was affect too many things

@srkoga
Copy link

srkoga commented Mar 25, 2020

@tkminh

I added the script but it doesn't work for me.

@tkminh
Copy link
Author

tkminh commented Mar 26, 2020

@Thaina right, we must do that, maybe Unity ignore that file when building to APK. Hope they will fix it in some early release.

@srkoga can you try to copy the xml in Assets\Plugins\Android\Firebase\res\values\googleservices.xml to the correct file google-services.xml
then try again.

@srkoga
Copy link

srkoga commented Mar 28, 2020

As I said before, the problem is in the generate_xml_from_google_services_json exe and py files.

I made a new project, installed firebase sdk 6.13.0. I put google-services.json in the Assets folder. I created the apk and ran it, and it didn't work.

I downloaded another version of sdk 6.8.0 and replaced only those files, without changing maintemplate or any other file. I created the apk and ran it ... it worked on the first try. :)

And when opening the Firebase menu in unity, no error appears.

I will continue my project this way because I already lost more than a week with this error.

unity 2019.3.7f1 + sdk 6.13.0 + with sdk files 6.8.0 = :)

Thank you all for your help.

@firebase firebase locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-info Need information for the developer type: question
Projects
None yet
Development

No branches or pull requests

6 participants