Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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

Discussion in 'Android' started by minhtk, Feb 23, 2020.

  1. minhtk

    minhtk

    Joined:
    May 27, 2013
    Posts:
    3
    Hi all,

    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)
    Firebase.AppUtilPINVOKE:pollCallbacks()
    Firebase.AppUtil:pollCallbacks() (at Z:\tmp\tmp.BahqeQHBdV\firebase\app\client\unity\proxy\AppUtil.cs:32)


    I downloaded the google-services.json from firebase project, and copy to Assets folder, but cannot work. Tried to export to gradle project and there is a file no file google-services.json, but it has a file google-services-desktop.json ? Did I make something wrong, please help.
     
  2. minhtk

    minhtk

    Joined:
    May 27, 2013
    Posts:
    3
    Please help !!!
     
  3. minhtk

    minhtk

    Joined:
    May 27, 2013
    Posts:
    3
    I solved it by adding below in the mainTemplate.gradle



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

    }
    }
     
  4. breakphones

    breakphones

    Joined:
    Dec 5, 2015
    Posts:
    2
    hi, have you a sample to show to me, i have the same problem but i don't understand how to implement correctly your solution, thanks ;-)
     
  5. breakphones

    breakphones

    Joined:
    Dec 5, 2015
    Posts:
    2



    apply plugin: 'com.android.library'
    **APPLY_PLUGINS**

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    **DEPS**}

    android {

    sourceSets {
    main {
    //res.srcDirs += '<fullpath>\\Assets\\Plugins\\Android\\Firebase\\res\\values\\google-services.xml'

    ???

    //res.srcDirs += 'Assets/Plugins/Android/Firebase/res/values/google-services.xml'

    }
    }


    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
    }



    aaptOptions {
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**PACKAGING_OPTIONS**
    }**REPOSITORIES****SOURCE_BUILD_SETUP**
    **EXTERNAL_SOURCES**

    //apply plugin: 'com.google.gms.google-services'
     
  6. Muntasir

    Muntasir

    Joined:
    Sep 24, 2012
    Posts:
    2
    I am having same error: its named as google-services-desktop.json.
     
  7. I_Gamer_Karthi

    I_Gamer_Karthi

    Joined:
    Jan 1, 2020
    Posts:
    1
    In Unity 2020, all Android resources must be in directories with a .androidlib suffix. If your project is using a Firebase SDK that generates an Assets/Plugins/Android/Firebase directory, rename it to Assets/Plugins/Android/Firebase.androidlib. Make sure it contains AndroidManifest.xml, project.properties and res/values/google-services.xml.
     
  8. laxe91

    laxe91

    Joined:
    Aug 31, 2019
    Posts:
    1
    Thanks a lot @I_Gamer_Karthi you just saved me.

    I had errors like this when trying to connect with Firebase :

    NullReferenceException: Object reference not set to an instance of an object.

    and I saw also this error :

    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 was getting crazy after one day I didn't understand why Firebase was not working anymore migrating from Unity 2019 to Unity 2020.
    Renaming the folder to Firebase.androidlib is what solved my issue.
     
    ritesh_khokhani likes this.
  9. Michalczechow

    Michalczechow

    Joined:
    Oct 13, 2020
    Posts:
    1
    In my case Special sign in filepath caused this error!
     
  10. ritesh_khokhani

    ritesh_khokhani

    Joined:
    Jun 26, 2013
    Posts:
    47
    This solved my issue, thanks @I_Gamer_Karthi you saved my time and commitment
     
  11. baldodavi

    baldodavi

    Joined:
    Nov 9, 2017
    Posts:
    5
    Thanks a lot, your hint solve my issue. Take a look also to package name if you come from 2019 unity version because 2020 change package name on the base of game parameters.
     
    ritesh_khokhani likes this.
  12. Owig

    Owig

    Joined:
    Mar 14, 2022
    Posts:
    1
    it seems the solution game karthi solve this problem,
    i am little bit late here but stuck in this problem..
    i dont know how to implement the solution u gave me
    if anyone active please show me step by step.
    thnk u very much..
     
  13. ALEKS_YT

    ALEKS_YT

    Joined:
    Nov 20, 2018
    Posts:
    4
    I still have that issue and renaming it from firebaseapp.androidlib to firebase.androidlib doesnt seem to work
     
    gabagpereira likes this.
  14. darklord0087

    darklord0087

    Joined:
    May 19, 2021
    Posts:
    1
    For everyone who have the folder named "Firebase" inside "Assets/Plugins/Android" above listed solution by @I_Gamer_Karthi works. If you dont even see the "Firebase" folder and keep getting this error "Assembly 'Packages/com.google.firebase.app/Firebase/Editor/Firebase.Editor.dll' will not be loaded due to errors: Unable to resolve reference 'UnityEditor.iOS.Extensions.Xcode", all you need to do is restart unity after installing Firebase SDK.
     
  15. srivishnu_unity

    srivishnu_unity

    Joined:
    Feb 8, 2023
    Posts:
    4
    I get the same error "failed to read firebase options from the app's resources" when building, none of the solutions above work for me. Did anyone figure it out?
     
  16. unity_1D70F7B33A875AEDDCD2

    unity_1D70F7B33A875AEDDCD2

    Joined:
    Sep 6, 2023
    Posts:
    2
    IS it working or not?
     
  17. unity_1D70F7B33A875AEDDCD2

    unity_1D70F7B33A875AEDDCD2

    Joined:
    Sep 6, 2023
    Posts:
    2
    Can this Assets/Plugins/Android/Firebase.androidlib AS LIKE IT , I mean you using a new name of folder with using '.' it is same as shown by you?