Android 4.1 crashes with this plugin and latest play services #1051
Comments
@mlabarca hey, I took a look at your stack trace:
and nowhere in there does a part of the Push Plugin java code get executed. If you comment out the call to |
Unfortunately, yeah. Even with init 'on' it registers without issues and i |
@mlabarca I think what you should concentrate on is looking for spots in your code that attempt to load files from the assets folder on Android. That is what the stack trace indicates to me. |
@macdonst I thought the same at first, but it doesn't really explain why it works with more recent android devices and when removing the plugin. |
@mlabarca first thing I'd do would be to delete your projects Can you send me what your |
@macdonst Sorry for the delay.
and when is it called:
and cordova service returns a promise that resolves when the device is ready like this:
This doesn't seem the issue to me since like I've said before, I get the token without problems and I haven't had any issues in recent versions and the app initializes. It's just on an unrelated login action after login credential are input by the user where I send the token to the server that the crash happens from version 1.4 onwards. Hope this helps at least :/ |
@mlabarca there is nothing in the code that you posted that has anything to do with loading anything from the assets folder so I feel as if the push plugin is not to blame here. When you go to the login screen are you trying to load something from assets that a) does not exist or b) has a special character like |
@macdonst Something I've just noticed (not sure if it's related) comparing tokens with recent and old plugin versions. For the same phone in the old deprecated plugin I'm receiving a token like APA91bHiZJoSgvS2EJvoOCjl0UzGUBInV6OkDiGYtQ6vPCZnegyv.... but from this plugin in more recent phones i receive **chLNI95DAOo:**APA91bHiZJoSgvS2EJvoOCjl0UzGUBInV6OkDiGYt.... Isn't this something that happens when firing the plugin before a device ready event? notifications do work, though. |
@mlabarca the old plugin used the gcm.jar to get the registration ID. This plugin uses updated libraries gcm and google instance ID. That is why the registration ID looks a bit different. You are getting it in the correct format. |
Closing, inactivity |
To anyone who is lost in a similar issue and uses angular, this was not a problem with the push plugin per se. GCM tokens can sometimes be in the form of '**chLNI95DAOo:**APA91bHiZJoS...'. This small colon that should be present seems to be generated in mostly android versions (Hence why it don't see the issue happen in android >4.4), when sent in an ajax request with the wrong encoding, crashed the app since it interpreted it as accessing a local non-existent template instead of the ajax request. Simply encoding that token with encodeURIcomponent in an $http interceptor and parsing it at the server fixed the issue. So sorry for the inconvenience 😞 |
This thread has been automatically locked. |
Expected Behaviour
App executes normally without crashes.
Actual Behaviour
Push actually registers successfully and I get a token, but for some reason my app crashes in an unreleated part of my app. (Login) When the plugin is removed, and actually replaced with the deprecated version (com.phonegap.plugins.pushplugin) the app works normally with push notifications and all.
Reproduce Scenario (including but not limited to)
Run an app with this plugin (even without calling init() ) in a device with the specs below.
Steps to Reproduce
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Android 4.1.2
(Android) What device vendor (e.g. Samsung, HTC, Sony...)
Samsung Galaxy s3 Mini. It works perfectly in an LG G3 stylus (android 5) and a Moto X play (Android 6)
Cordova CLI version and cordova platform version
Plugin version
Latest version.
Sample Push Data Payload
Sample Code that illustrates the problem
Logs taken while reproducing problem
Specific part of the log with the crash:
Full logcat:
https://gist.github.com/mlabarca/2fa8688c74e4b615793bd64c1d3836a9
Notes:
At first I though this was also related to #909, But play services in the device in question is at the most recent version (9.2.56). I also attempted re-applying
this commit in my fork : 2fecb9c to lock down the services requirement(both in plugin.xml and push.gradle) but that didn't work either. I'm starting to think this is a separate issue with something else bundled with this plugin.
I'm seeing this building with phonegap build and also in cli.
The text was updated successfully, but these errors were encountered: