cordova-plugin-firebase-analytics: Missing google_app_id. Firebase Analytics disabled.

When I fire a log event, I get the following error: 12-30 16:22:03.856: E/FA(17787): Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI

any idea what;s the problem?

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Manually entering the following tag in platforms/android/res/values/string.xml worked for me <string name="google_app_id">1:12345:android:abc123</string> The value to enter will be the value of the mobilesdk_app_id key in google-services.json

Manually entering the following tag in platforms/android/res/values/string.xml worked for me <string name="google_app_id">1:12345:android:abc123</string> The value to enter will be the value of the mobilesdk_app_id key in google-services.json

thanx you this is the best solution ever

@pablo-gonzalez I’m not a mantainer of this plugin/repo, I was just trying to help based on my own experience. I did try the cordova-plugin-firebase before this one, so maybe that’s why I have the correct setup.

This project is maintained with the free time and good will of people, so please don’t be rude implying it’s not maintained because you didn’t get a response. Maybe just nobody knows or has the same problem as you do. If you know what solves the issue, send a PR instead and you will help maintaining this.

Because of the lack of response to issues for this plugin I guess it is no longer maintained. However this fix could be useful for someone facing the same issue than me.

I realized that the google_app_di and google_api_id were missing in string.xml file.

Then I compared the code of this plugin with this one: https://github.com/arnesson/cordova-plugin-firebase

Thus to fix this issue you have to add these lines to plugin.xml before AndroidManifest.xml entry:

		<config-file parent="/resources" target="res/values/strings.xml">
			<string name="google_app_id">@string/google_app_id</string>
		</config-file>
		<config-file parent="/resources" target="res/values/strings.xml">
			<string name="google_api_key">@string/google_api_key</string>
		</config-file>

and add these lines to android.json before AndroidManifest.xml entry:

            "res/values/strings.xml": {
                "parents": {
                    "/resources": [
                        {
                            "xml": "<string name=\"google_app_id\">@string/google_app_id</string>",
                            "count": 1
                        },
                        {
                            "xml": "<string name=\"google_api_key\">@string/google_api_key</string>",
                            "count": 1
                        }
                    ]
                }
            },

Doing that variables will be added to string.xml and every time you build the project they will be updated using values in GoogleService-Info.plist for ios and google-services.json for android.

@FdezRomero If you want to reproduce this issue just create a blank project with this plugin using cordova or ionic for android. Then you will realized that variables are not in string.xml after installing.

Manually entering the following tag in platforms/android/res/values/string.xml worked for me <string name="google_app_id">1:12345:android:abc123</string> The value to enter will be the value of the mobilesdk_app_id key in google-services.json

Can you bro tell me where is platforms/android/res/values/string.xml in flutter folder structure using Vs code . I am strugging this issue so many days

Solved this error on cordova-android@6.2.3 by adding this to config.xml:

<config-file parent="/resources" target="res/values/strings.xml">
    <string name="google_app_id">YOUR_APP_ID</string>
    <string name="google_api_key">YOUR_API_KEY</string>
</config-file>

…which seems to stop the console throwing the missing google_app_id error.

However, I am also experiencing a different issue now:

W/GooglePlayServicesUtil(19217): Google Play services out of date.  Requires 11020000 but found 8703036
W/FA      (19217): Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}

Which suggests the libraries being used in the plugin are too old and must be updated to be used.

Ok guys, I found my solution, hope it helps. The problem is the hook, in my case (android) in the strings.xml android file there are not the google_app_id and google_api_key references. So I put my hands on the plugin very roughly and tuned it in order to take care also of this case.

The code:

if(!strings.includes('<string name="google_app_id">')) { strings = strings.replace('</resources>','\t<string name="google_app_id">' + json.client[0].client_info.mobilesdk_app_id + '</string>\n</resources>'); } if(!strings.includes('<string name="google_api_key">')){ strings = strings.replace('</resources>','\t<string name="google_api_key">' + json.client[0].api_key[0].current_key + '</string>\n</resources>'); }

after the list of strings.replace and before fs.writeFileSync(path.join(androidFolder, "res/values/strings.xml"), strings);

on the plugins\cordova-plugin-firebase-hooks\hooks\android\copy-google-services.js file.

Please @chemerisuk give a look here and if you agree update the plugin (I’ve worked only on the android case…).