OneSignal / OneSignal-Xamarin-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Xamarin app with OneSignal. https://onesignal.com
Other
104 stars 50 forks source link

Google Play Services Library Error #197

Open tiagobpompeo opened 4 years ago

tiagobpompeo commented 4 years ago

Description: Hello, in our application uses this library, to use Push to send on Android. It turns out that even with the updated libraries in our environment, we are receiving no notifications. When this happens, we access the OneSignal console to check for any error logs and discover the following message reported in the "subscribed" field, a "Google Play Services Library Error" message, occurs frequently, at some point until it has it stops occurring but unsteadily occurs again. Understanding the problems related to google's "Play Services".

Environment

  1. What version of the Xamarin SDK are you using? 3.8.1
  2. How did you add the SDK to your project (eg. nuget) Nuget.org

Steps to Reproduce Issue:

Step by step to reproduce or error

1 - Install a Library in the Xamarin.Android project and make the settings 2 - Build an app and see the return on the One Signal Console 3 - Check the error in the "Audience" fields under "All users" and then in the "Subscribed" field, Google Play Services Library Error message 4 - Try Push , device dont receive

Any occurrence of another application?

Any suggestions to correct or reported error Anything else:

(crash stacktraces, as well as any other information here)

jkasten2 commented 4 years ago

@tiagobpompeo Please check the Android logcat for more details on the cause of the "Google Play Services Library" error. See the following on how to get logcat messages https://documentation.onesignal.com/docs/troubleshooting-android#how-to-get-a-crash-or-error-log-from-an-android-device

Then post the log entries here and we can follow up.

tiagobpompeo commented 4 years ago

@jkasten2

Time Device Name Type PID Tag Message
05-11 15:31:28.119 Samsung SM-G611MT Warning 18288 OneSignal Both GCM & FCM Libraries detected! Please remove the deprecated GCM library.
Time Device Name Type PID Tag Message
05-11 15:31:29.084 Samsung SM-G611MT Error 18288 OneSignal Unknown error getting FCM Token
Time Device Name Type PID Tag Message
05-11 15:31:28.700 Samsung SM-G611MT Info 18288 OneSignal Querying DB for notifs to restore: created_time > 1588617088 AND dismissed = 0 AND opened = 0 AND is_summary = 0 AND expire_time > 1589221888
Time Device Name Type PID Tag Message
05-11 15:31:28.697 Samsung SM-G611MT Info 18288 OneSignal Restoring notifications
Time Device Name Type PID Tag Message
05-11 15:30:58.790 Samsung SM-G611MT Debug 18288 AMIL ERROR ONESIGNAL: Object reference not set to an instance of an object
Time Device Name Type PID Tag Message
05-11 15:31:29.084 Samsung SM-G611MT Error 18288 OneSignal java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken(java.lang.String, java.lang.String)' on a null object reference at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:95) at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97) at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37) at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84) at java.lang.Thread.run(Thread.java:764)
tiagobpompeo commented 4 years ago

Another One

Time Device Name Type PID Tag Message 05-12 10:19:00.973 Samsung SM-G611MT Warning 20787 OneSignal Location permission exists but GoogleApiClient timed out. Maybe related to mismatch google-play aar versions.

jkasten2 commented 4 years ago

@tiagobpompeo Thanks for the log. The error points to some issue with a Firebase App not being initialized.

java.lang.NullPointerException: Attempt to invoke virtual method
java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken(java.lang.String, java.lang.String)' on a null object reference
at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:95) at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97)
at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37) 
at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84)
at java.lang.Thread.run(Thread.java:764)

I recommend removing the GCM from your project as this could be the cause

Both GCM & FCM Libraries detected! Please remove the deprecated GCM library.

Can you check for any firebase or FCM errors before this log?

Lastly what version of FCM is in your project?

tiagobpompeo commented 4 years ago

@jkasten2

Remove the GCM Library , but stilll get error like :

In Sequence

Time Device Name Type PID Tag Message
05-13 12:25:07.036 Samsung SM-G611MT Info 14891 OneSignal Device registered, UserId = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
05-13 12:25:01.770 Samsung SM-G611MT Error 14891 OneSignal java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken(java.lang.String, java.lang.String)' on a null object reference              at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:95)      at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97)              at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37) at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84)         at java.lang.Thread.run(Thread.java:764)
05-13 12:25:01.770 Samsung SM-G611MT Error 14891 OneSignal Unknown error getting FCM Token
05-13 12:25:01.335 Samsung SM-G611MT Info 14891 OneSignal Querying DB for notifs to restore: created_time > 1588778701 AND dismissed = 0 AND opened = 0 AND is_summary = 0 AND expire_time > 1589383501
05-13 12:25:01.332 Samsung SM-G611MT Info 14891 OneSignal Restoring notifications
jkasten2 commented 4 years ago

@tiagobpompeo Hmm, odd there is no other errors / warnings before java.lang.NullPointerException, there should be some other details before this in the logcat.

If you can share a project reproducing the issue we can take a look.

tiagobpompeo commented 4 years ago

@jkasten2

We used another library in our project for crash capture and bug analysis, that library is Xamarin.Android.Crashlytics 2.9.4.4. We noticed that when installing and using it in its context, this has directly affected the OneSignal, causing the errors already referenced in the logs of entries. For our adjustment we had to uninstall the library referenced above and any dependencies on it, as well as reinstall Google Play Services libraries such as:

Xamarin.GooglePlayServices.Analytics.Impl Xamarin.GooglePlayServices.Analytics Xamarin.GooglePlayServices.TagManager.V4.Impl

By doing this, the entire OneSignal flow is back to working correctly without registration errors or "Google Play Services Error".

Is this too weird for me, any questions about how to solve this?

Does this package affect OneSignal's and why?

Can you help us?

jkasten2 commented 4 years ago

OneSignal initializes it's own Firebase App Instance so it should be isolated from your default instance or any other libraries. https://github.com/OneSignal/OneSignal-Android-SDK/blob/3.13.2/OneSignalSDK/onesignal/src/main/java/com/onesignal/PushRegistratorFCM.java#L98-L110

There are only two reasons I can think of why adding those 3 dependencies would have any effect.

  1. The Firebase App Instance depends on these but at a different version. Normally this results in errors with Java classes not being found at build or runtime.
  2. There is a runtime bug with Firebase when these libraries are added. I recommend making sure you have the latest of these libraries.

We will need more detailed logs or a way to reproduce it if the above does not help.

tiagobpompeo commented 4 years ago

1 -Without - https://www.nuget.org/packages/Xamarin.Android.Crashlytics/ Package Installed, see logs

Thats Found Well

Time Device Name Type PID Tag Message
05-18 17:08:11.777 Samsung SM-G611MT Info 8016 OneSignal Device registered, UserId = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Time Device Name Type PID Tag Message
05-18 17:14:17.730 Samsung SM-G611MT Info 11954 OneSignal Device registered, push token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
05-18 17:14:17.102 Samsung SM-G611MT Info 11954 OneSignal Querying DB for notifs to restore: created_time > 1589228057 AND dismissed = 0 AND opened = 0 AND is_summary = 0 AND expire_time > 1589832857
05-18 17:14:17.099 Samsung SM-G611MT Info 11954 OneSignal Restoring notifications

2 - With https://www.nuget.org/packages/Xamarin.Android.Crashlytics/ Package Installed, see logs

Time Device Name Type PID Tag Message
05-13 12:25:07.036 Samsung SM-G611MT Info 14891 OneSignal Device registered, UserId = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
05-13 12:25:01.770 Samsung SM-G611MT Error 14891 OneSignal java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.iid.FirebaseInstanceId.getToken(java.lang.String, java.lang.String)' on a null object reference              at com.onesignal.PushRegistratorFCM.getToken(PushRegistratorFCM.java:95)      at com.onesignal.PushRegistratorAbstractGoogle.attemptRegistration(PushRegistratorAbstractGoogle.java:97)              at com.onesignal.PushRegistratorAbstractGoogle.access$100(PushRegistratorAbstractGoogle.java:37) at com.onesignal.PushRegistratorAbstractGoogle$1.run(PushRegistratorAbstractGoogle.java:84)         at java.lang.Thread.run(Thread.java:764)
05-13 12:25:01.770 Samsung SM-G611MT Error 14891 OneSignal Unknown error getting FCM Token
05-13 12:25:01.335 Samsung SM-G611MT Info 14891 OneSignal Querying DB for notifs to restore: created_time > 1588778701 AND dismissed = 0 AND opened = 0 AND is_summary = 0 AND expire_time > 1589383501
05-13 12:25:01.332 Samsung SM-G611MT Info 14891 OneSignal Restoring notifications
rafamatosaraujo commented 4 years ago

One of Xamarin.Firebase.Core dependencies is outdated after installation. Update Xamarin.Firebase.Measurement.Connector.Impl to version 71.1705.1 and it should fix the problem.

tiagobpompeo commented 4 years ago

@gifs88 I will try it

tiagobpompeo commented 4 years ago

I have opened a issue about that in Xamarin https://github.com/xamarin/XamarinComponents/issues/861

LittleBoxOfChicken commented 3 years ago

Already looked at the other issue but are there any people in this issue that have found a solution yet?