Closed Tarekajaj closed 7 years ago
Check out #5, it worked for me.
Hi. I am facing the same issue.
I am using Ionic framework to create a test application.
I put the google-services.json file in the root folder. Once the build is made the file is copied to platforms/android as expected without errors.
I left the json file in folder as advised and then removed the plugin and android platform. After reinstalling platform and plugin same results :(
adb logcat -v time | grep Firebase
01-23 18:22:38.840 I/FirebaseInitProvider(19839): FirebaseApp initialization unsuccessful
01-23 18:22:39.681 D/FirebaseAnalyticsPlugin(19839): Starting Firebase Analytics plugin
01-23 18:22:39.711 E/FA (19839): Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI
01-23 18:22:42.395 W/FA (19839): Failed to retrieve Firebase Instance Id
01-23 18:22:42.396 E/FA-SVC ( 2026): Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI
adb logcat -v time | grep GoogleService
01-23 18:22:39.700 E/FA (19839): GoogleService failed to initialize, status: 10, Missing google app id value from from string resources with name google_app_id.
Am I missing anything? Is google_app_id one of the entries in google-services.json? Where is Firebase initialization trying to get that value from?
Thanks in advance, Pablo
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.
@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.
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.
First all I am not implying I am just saying the truth about the lack of responses to other issues also. I am not complaining about you, in fact you were the only one answering to help.
Second: because I found a possible fix to this I am sharing it to help others.
@pablo-gonzalez I've updated cordova-plugin-firebase-hooks according to your comments. Let me know if it solves your issue (you need to reinstall the plugin).
Hi @chemerisuk
I have created a new blank project for testing using Ionic.
If you install the plugin using cordova plugin add cordova-plugin-firebase-analytics
cordova-plugin-firebase-hooks is not updated with the changes you made.
I had to force uninstall and then install from git:
ionic plugin rm cordova-plugin-firebase-hooks --force
ionic plugin add https://github.com/chemerisuk/cordova-plugin-firebase-hooks
After that I can confirm that the change you made fixed the issue related to google variables.
However I am getting some errors:
pablo@pablo-Inspiron-7520:~$ adb shell setprop log.tag.FA VERBOSE
pablo@pablo-Inspiron-7520:~$ adb shell setprop log.tag.FA-SVC VERBOSE
pablo@pablo-Inspiron-7520:~$ adb logcat -v time -s FA FA-SVC
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
01-30 07:20:32.621 I/FA ( 1409): App measurement is starting up, version: 10084
01-30 07:20:32.621 I/FA ( 1409): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
01-30 07:20:32.621 D/FA ( 1409): Debug-level message logging enabled
01-30 07:20:32.621 D/FA ( 1409): AppMeasurement singleton hash: 1384279852
01-30 07:20:32.633 V/FA ( 1409): Collection enabled
01-30 07:20:32.633 V/FA ( 1409): App package, google app id: com.ionicframework.fatest618272, 1:53108152975:android:445ccf3b39fb9955
01-30 07:20:32.633 I/FA ( 1409): To enable faster debug mode event logging run:
01-30 07:20:32.633 I/FA ( 1409): adb shell setprop debug.firebase.analytics.app com.ionicframework.fatest618272
01-30 07:20:32.637 V/FA ( 1409): Registered activity lifecycle callback
01-30 07:20:32.641 V/FA ( 1409): onActivityCreated
01-30 07:20:32.641 V/FA ( 1409): State of service unknown
01-30 07:20:32.641 V/FA ( 1409): Checking service availability
01-30 07:20:32.641 W/FA ( 1409): Service invalid
01-30 07:20:32.641 V/FA ( 1409): Setting useService: false
01-30 07:20:32.641 V/FA ( 1409): Using local app measurement service
01-30 07:20:37.589 V/FA ( 1409): Using local app measurement service
01-30 07:20:37.593 V/FA ( 1409): Connection attempt already in progress
01-30 07:20:37.593 V/FA ( 1409): Activity resumed, time: 326482
01-30 07:20:37.593 V/FA ( 1409): Local AppMeasurementService is starting up
01-30 07:20:37.665 V/FA ( 1409): Bound to IMeasurementService interface
01-30 07:20:37.665 V/FA ( 1409): Connected to service
01-30 07:20:37.669 V/FA ( 1409): Processing queued up service tasks: 2
01-30 07:20:39.633 I/FA ( 1409): This instance being marked as an uploader
01-30 07:20:45.541 D/FA ( 1409): Unable to get advertising id: java.lang.NullPointerException: com.google.android.gms.internal.zzatl.zzfK(Unknown Source)
01-30 07:20:45.541 D/FA ( 1409): Setting user property: _fot, 1485781200000
01-30 07:20:45.545 D/FA ( 1409): User property set: _fot, 1485781200000
01-30 07:20:45.545 V/FA ( 1409): Logging event: origin=auto,name=_f,params=Bundle[{_c=1, _r=1, _pfo=0, _sys=0, _uwa=0, _sysu=0}]
01-30 07:20:45.549 V/FA ( 1409): Saving event, name, data size: _f, 71
01-30 07:20:45.549 V/FA ( 1409): Event recorded: Event{appId='com.ionicframework.fatest618272', name='_f', params=Bundle[{_c=1, _o=auto, _r=1, _pfo=0, _sys=0, _uwa=0, _sysu=0}]}
01-30 07:20:45.553 V/FA ( 1409): Upload scheduled in approximately ms: 500
01-30 07:20:45.553 V/FA ( 1409): Background event processing time, ms: 9
01-30 07:20:45.553 V/FA ( 1409): Logging event: origin=auto,name=_e,params=Bundle[{_et=1}]
01-30 07:20:45.557 V/FA ( 1409): Saving event, name, data size: _e, 23
01-30 07:20:45.557 V/FA ( 1409): Event recorded: Event{appId='com.ionicframework.fatest618272', name='_e', params=Bundle[{_o=auto, _et=1}]}
01-30 07:20:45.557 V/FA ( 1409): Upload scheduled in approximately ms: 9994
01-30 07:20:45.561 V/FA ( 1409): Background event processing time, ms: 6
01-30 07:20:45.741 V/FA ( 1409): Inactivity, disconnecting from the service
01-30 07:20:45.745 V/FA ( 1409): onUnbind called for intent. action: com.google.android.gms.measurement.START
01-30 07:20:45.745 V/FA ( 1409): Local AppMeasurementService is shutting down
01-30 07:20:46.797 D/FA ( 1409): Setting app measurement enabled (FE): false
01-30 07:20:46.797 V/FA ( 1409): Setting measurementEnabled: false
01-30 07:20:46.801 V/FA ( 1409): Using local app measurement service
01-30 07:20:46.961 V/FA ( 1409): Local AppMeasurementService is starting up
01-30 07:20:47.009 V/FA ( 1409): Bound to IMeasurementService interface
01-30 07:20:47.013 V/FA ( 1409): Connected to service
01-30 07:20:47.013 V/FA ( 1409): Processing queued up service tasks: 1
01-30 07:20:47.593 V/FA ( 1409): Session started, time: 336485
01-30 07:20:47.593 D/FA ( 1409): Event not sent since app measurement is disabled
01-30 07:20:52.017 V/FA ( 1409): Inactivity, disconnecting from the service
01-30 07:20:52.017 V/FA ( 1409): onUnbind called for intent. action: com.google.android.gms.measurement.START
01-30 07:20:52.017 V/FA ( 1409): Local AppMeasurementService is shutting down
01-30 07:20:55.561 V/FA ( 1409): Local receiver got: com.google.android.gms.measurement.UPLOAD
01-30 07:20:55.565 V/FA ( 1409): Local AppMeasurementService is starting up
01-30 07:20:55.565 V/FA ( 1409): Local AppMeasurementService called. startId, action: 1, com.google.android.gms.measurement.UPLOAD
01-30 07:20:55.565 D/FA ( 1409): Uploading events. Elapsed time since last upload attempt (ms): 10013
01-30 07:20:55.569 V/FA ( 1409): Fetching remote configuration: com.ionicframework.fatest618272
01-30 07:20:55.573 V/FA ( 1409): Local AppMeasurementService processed last upload request
01-30 07:20:55.573 V/FA ( 1409): Local AppMeasurementService is shutting down
01-30 07:20:55.945 V/FA ( 1409): Parsed config. version, gmp_app_id: 1485517921953000, 1:53108152975:android:445ccf3b39fb9955
01-30 07:20:55.949 V/FA ( 1409): Successfully fetched config. Got network response. code, size: 200, 95
01-30 07:20:55.953 V/FA ( 1409): Saving bundle, size: 374
01-30 07:20:55.957 D/FA ( 1409): Uploading events. Elapsed time since last upload attempt (ms): 10396
01-30 07:20:55.957 V/FA ( 1409): No expired configs for apps with pending events
01-30 07:24:39.097 I/FA ( 1560): App measurement is starting up, version: 10084
01-30 07:24:39.097 I/FA ( 1560): To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
01-30 07:24:39.097 D/FA ( 1560): Debug-level message logging enabled
01-30 07:24:39.097 D/FA ( 1560): AppMeasurement singleton hash: 1384311052
01-30 07:24:39.113 V/FA ( 1560): Collection enabled
01-30 07:24:39.113 V/FA ( 1560): App package, google app id: com.ionicframework.fatest618272, 1:53108152975:android:445ccf3b39fb9955
01-30 07:24:39.113 I/FA ( 1560): To enable faster debug mode event logging run:
01-30 07:24:39.113 I/FA ( 1560): adb shell setprop debug.firebase.analytics.app com.ionicframework.fatest618272
01-30 07:24:39.121 V/FA ( 1560): Registered activity lifecycle callback
01-30 07:24:39.125 V/FA ( 1560): Using local app measurement service
01-30 07:24:39.125 V/FA ( 1560): onActivityCreated
01-30 07:24:39.433 V/FA ( 1560): Using local app measurement service
01-30 07:24:39.433 V/FA ( 1560): Connection attempt already in progress
01-30 07:24:39.433 V/FA ( 1560): Activity resumed, time: 568324
01-30 07:24:39.437 V/FA ( 1560): Local AppMeasurementService is starting up
01-30 07:24:39.733 V/FA ( 1560): Bound to IMeasurementService interface
01-30 07:24:39.737 V/FA ( 1560): Connected to service
01-30 07:24:39.737 V/FA ( 1560): Processing queued up service tasks: 2
01-30 07:24:39.745 I/FA ( 1560): This instance being marked as an uploader
01-30 07:24:39.757 D/FA ( 1560): Unable to get advertising id: java.lang.NullPointerException: com.google.android.gms.internal.zzatl.zzfK(Unknown Source)
01-30 07:24:40.925 D/FA ( 1560): Setting app measurement enabled (FE): false
01-30 07:24:40.925 V/FA ( 1560): Setting measurementEnabled: false
01-30 07:24:45.937 V/FA ( 1560): Inactivity, disconnecting from the service
01-30 07:24:45.937 V/FA ( 1560): onUnbind called for intent. action: com.google.android.gms.measurement.START
01-30 07:24:45.937 V/FA ( 1560): Local AppMeasurementService is shutting down
01-30 07:24:49.437 V/FA ( 1560): Session started, time: 578330
01-30 07:24:49.441 D/FA ( 1560): Event not sent since app measurement is disabled
01-30 07:25:01.625 D/FA ( 1560): Event not sent since app measurement is disabled
01-30 07:28:32.945 V/FA ( 1560): Recording user engagement, ms: 233512
01-30 07:28:32.945 V/FA ( 1560): Using local app measurement service
01-30 07:28:32.949 V/FA ( 1560): Activity paused, time: 801832
01-30 07:28:32.949 V/FA ( 1560): Local AppMeasurementService is starting up
01-30 07:28:32.949 V/FA ( 1560): Bound to IMeasurementService interface
01-30 07:28:32.953 D/FA ( 1560): Event not sent since app measurement is disabled
01-30 07:28:32.953 V/FA ( 1560): Connected to service
01-30 07:28:32.953 V/FA ( 1560): Processing queued up service tasks: 1
01-30 07:28:37.953 V/FA ( 1560): Inactivity, disconnecting from the service
01-30 07:28:37.957 V/FA ( 1560): onUnbind called for intent. action: com.google.android.gms.measurement.START
01-30 07:28:37.957 V/FA ( 1560): Local AppMeasurementService is shutting down
01-30 07:29:03.733 V/FA ( 1560): onActivityCreated
01-30 07:29:03.753 V/FA ( 1560): Using local app measurement service
01-30 07:29:03.757 V/FA ( 1560): Activity resumed, time: 832646
01-30 07:29:03.797 V/FA ( 1560): Local AppMeasurementService is starting up
01-30 07:29:03.837 V/FA ( 1560): Bound to IMeasurementService interface
01-30 07:29:03.837 V/FA ( 1560): Connected to service
01-30 07:29:03.837 V/FA ( 1560): Processing queued up service tasks: 1
01-30 07:29:04.393 D/FA ( 1560): Setting app measurement enabled (FE): false
01-30 07:29:04.393 V/FA ( 1560): Setting measurementEnabled: false
01-30 07:29:04.397 D/FA ( 1560): Unable to get advertising id: java.lang.NullPointerException: com.google.android.gms.internal.zzatl.zzfK(Unknown Source)
01-30 07:29:09.401 V/FA ( 1560): Inactivity, disconnecting from the service
01-30 07:29:09.401 V/FA ( 1560): onUnbind called for intent. action: com.google.android.gms.measurement.START
01-30 07:29:09.405 V/FA ( 1560): Local AppMeasurementService is shutting down
01-30 07:29:18.849 D/FA ( 1560): Event not sent since app measurement is disabled
01-30 07:29:50.477 V/FA ( 1560): Recording user engagement, ms: 46724
01-30 07:29:50.481 V/FA ( 1560): Using local app measurement service
01-30 07:29:50.485 V/FA ( 1560): Activity paused, time: 879369
01-30 07:29:50.485 V/FA ( 1560): Local AppMeasurementService is starting up
01-30 07:29:50.485 D/FA ( 1560): Event not sent since app measurement is disabled
01-30 07:29:50.485 V/FA ( 1560): Bound to IMeasurementService interface
01-30 07:29:50.485 V/FA ( 1560): Connected to service
01-30 07:29:50.485 V/FA ( 1560): Processing queued up service tasks: 1
01-30 07:29:53.969 V/FA ( 1560): onActivityCreated
01-30 07:29:53.997 V/FA ( 1560): Activity resumed, time: 882890
01-30 07:29:54.621 D/FA ( 1560): Setting app measurement enabled (FE): false
01-30 07:29:54.621 V/FA ( 1560): Setting measurementEnabled: false
01-30 07:29:54.625 D/FA ( 1560): Unable to get advertising id: java.lang.NullPointerException: com.google.android.gms.internal.zzatl.zzfK(Unknown Source)
01-30 07:29:59.629 V/FA ( 1560): Inactivity, disconnecting from the service
01-30 07:29:59.629 V/FA ( 1560): onUnbind called for intent. action: com.google.android.gms.measurement.START
01-30 07:29:59.629 V/FA ( 1560): Local AppMeasurementService is shutting down
01-30 07:30:05.061 D/FA ( 1560): Event not sent since app measurement is disabled
^C
pablo@pablo-Inspiron-7520:~$
Is it mandatory to use the setEnabled? Any default value?
I have put window.cordova.plugins.firebase.analytics.setEnabled(true);
in the app initialization.
I have tried to log an event using window.cordova.plugins.firebase.analytics.logEvent("page_view", {page: "account"});
in the controller section but there is not confirmation in logs that it was successfully logged.
Apart of that there are several entries saying:
Event not sent since app measurement is disabled
Is that OK?
Is this an issue?
01-30 07:24:39.757 D/FA ( 1560): Unable to get advertising id: java.lang.NullPointerException: com.google.android.gms.internal.zzatl.zzfK(Unknown Source)
Thanks in advance.
Best regards, Pablo
setEnabled
call is not required. Analytics should be enabled by default
Read logs, you can enable extra logging in logcat
output using command
adb shell setprop log.tag.FA VERBOSE
Also you can check firebase console -> Analytics -> Events section.
On my device I also see a related error
Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.internal.zzacw.zzg
Therefore my guessing is that your error is not blocking. But make sure you have google-services.json
in the cordova root folder.
I have the same error. i have unistalled the plugin and reinstall this but doens't work. The data are correct.
i have the error: Missing google_app_id. Firebase Analytics disabled
Please help me to solve. It is an important bug
Hello, I also have the same error as lucav90
03-27 13:29:33.495: I/FirebaseInitProvider(21341): FirebaseApp initialization unsuccessful 03-27 13:29:33.675: D/FirebaseAnalyticsPlugin(21341): Starting Firebase Analytics plugin 03-27 13:29:33.685: I/FA(21341): adb shell setprop debug.firebase.analytics.app com.myapp.app 03-27 13:29:33.695: E/FA(21341): Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI
I am using cordova 6.4.0 and phonegap build / currently testing on android I added both google-services.json and GoogleService-Info.plist to the root of www folder.
With phonegap, I only have access to the config.xml, what info do I need to add in config.xml ?
thanks
I think I might have a track to follow but it is still not working
In the config.xml I am changing the widget node
<widget id="myapp" version="0.0.2" versionCode="026" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<edit-config file="res/values/strings.xml" mode="merge" target="/*">
<string name="google_app_id">1:XXXXXXXXXXXX:android:XXXXXXXXXXXX</string>
<string name="google_api_key">XXXXXXXXXXXXX-XXXXXXXXXXXXXXXX</string>
</edit-config>
@pablo-gonzalez 's answer work for me in cordova first add updated google-services.json file remove cordova-plugin-firebase-hooks plugin (use --force ) and add again using cordova plugin add https://github.com/chemerisuk/cordova-plugin-firebase-hooks then no more error
Hello @aniketbhoite
I have updated the google-service.json file and added
<gap:plugin name="cordova-plugin-firebase-hooks" source="npm" />
In my config.xml ( I am using Phonegap Build )
But I still have FirebaseApp initialization unsuccessful I think I have to edit the file res/values/strings.xml but my method doesn't seem to work : (
Apparently ... after discussing on the adobe forum. "The trick, Mr. Potter, is not minding it hurts." (Warning this solution is not working for me, but I this we can be close to one)
More seriously the trick is to
1- forget about the www.zip file if never it was your method of choice ( and use the git/bitbucket solution for compiling the source)
2- go to https://github.com/chemerisuk/cordova-plugin-firebase-analytics
3- fork the plugin to your account
4- edit your config.xml
<plugin spec="http://github.com/your_github_account/cordova-plugin-firebase-analytics.git" />
5- in your plugin's fork, in plugin.xml, inside of:
<platform name="android">
...
</platform>
add
<config-file parent="/resources" target="res/values/strings.xml">
<string name="google_app_id">XXXXXXXXXX</string>
</config-file>
<config-file parent="/resources" target="res/values/strings.xml">
<string name="google_api_key">XXXXXXXXXX</string>
</config-file>
6- pull updates and recompile
There are some tweeks to do, so far it is not working for me, but as I said I think the track is hot.
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
Hello thank you for your reply, I managed to make it working, I think I had a conflict with another plugin
thanks
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...).
Try version 0.10 from npm. Make sure you've read README to setup plugin correctly (there were some changes).
Hi. I'm still struggling with this error. The plugin works fine for iOS as per the instructions, but for android I can't get it to work. I get E/FA ( 2813): Missing google_app_id.
in my logs. The google-services.json
file has been added to the platforms/android
directory and I've tried to remove and add the plugin again but with no luck.
Is there anything I could do to further debug this issue?
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.
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
Just adding my experience with this error: I simply removed and re-added the plugin and the error went away.
anyone found how to fix this in firebase analytics to flutter intergration ? . am confused coz my firebase in app works as i can send notifications but cant do analytics
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
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