Cordova-plugin-firebase: Not working on Android (Invalid google_app_id), google-services.json not read properly

Created on 28 Aug 2017  ·  13Comments  ·  Source: arnesson/cordova-plugin-firebase

Hi,

I'm using this plugin with success with iOS, but i'm having trouble using it with Android.

The console log this error :

Invalid google_app_id. Firebase Analytics disabled.

My guess is that my google-services.json is not read correctly, because when I deleted it in platforms/android it doesn't change anything, got the same logs.

I tried to :

  • install the plugin with my up-to-date google-services.json file placed at the root of my cordova projects and without the config file, no changes, same results in both ways. I noticed that the google-services.json copied in platforms/android is always corrupted/empty.
  • Manually copy google-services.json in platforms/android, no changes.

Am I missing something ?

Ionic info log

cli packages: (/Users/thomas/Documents/Dev/WonderParents/Ionic/node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Android SDK Tools : 25.2.3
ios-deploy        : 1.9.0 
ios-sim           : 6.0.0 
Node              : v8.1.4
npm               : 5.3.0 
OS                : macOS Sierra
Xcode             : Xcode 8.3.3 Build version 8E3004b

Plugin version : 0.1.24

Test on simulator and real device

Most helpful comment

Have you installed the master version? (cordova plugin add https://github.com/arnesson/cordova-plugin-firebase)

All 13 comments

I think this problem is caused by the after_prepare script. The platform detection is faulty, the plugin script only runs the iOS part if iOS and Android are present:

// Copy key files to their platform specific folders
if (directoryExists(IOS_DIR)) {
    copyKey(PLATFORM.IOS);
} else if (directoryExists(ANDROID_DIR)) {
    copyKey(PLATFORM.ANDROID, updateStringsXml)
}

I changed that locally to detect the platform from the cordova context and I am preparing a pull request.

@ben-8409 Is possible to manually copy the config files for android ?

  • For iOS, I have to manually put the config fil inside of platforms/ios//ressources every single time I install the plugin, otherwise my config file is corrupted..

  • For android, nothing works. Even when I manually copy my config file ( google-services.json) inside of platforms/android.

I take a look at your commit, it seems like, manually copy the config file is not enough for android, there are values to changes in the string.xml file. That's why it doesn't work with android, isn't it ?

@ThomasKientz no, that is not sufficient since the plugin reads data from the files and puts that in the resources (on Android at least).

Until this if fixed in this repository, you could try to install the plugin from my fork and the branch:
https://github.com/ben-8409/cordova-plugin-firebase/tree/fix-android-not-configured-properly

This should work with
cordova plugin add https://github.com/ben-8409/cordova-plugin-firebase.git#fix-android-not-configured-properly

@ben-8409 Working great. Thanks SO much !

This bug is fixed ? Because I try with the last version of cordova-plugin-firebase and have the same error....

Yes, for me and some others, the bug is fixed, but you have to install from the git #master branch for now, as there has not been a new release yet.

How can I use the master version?

Il giorno 31 ago 2017, alle ore 10:30, Benjamin Geese notifications@github.com ha scritto:

Yes, for me and some others, the bug is fixed, but you have to install from the git #master branch for now, as there has not been a new release yet.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@lionalex use the master version : cordova plugin add https://github.com/arnesson/cordova-plugin-firebase

Thanks, work fine 👍

Still not working for me mate. I was working fine till 0.1.23 but after that i am not able to send any notification.

Got this working. It seems google-services.json copied by plugin was empty. Replaced it with original file and it started working.

Have you installed the master version? (cordova plugin add https://github.com/arnesson/cordova-plugin-firebase)

Was this page helpful?
0 / 5 - 0 ratings