Latest Play store service breaks phonegap-plugin-push #909

Closed
hereiam133 opened this Issue May 20, 2016 · 60 comments

Projects

None yet
@hereiam133

After Google released the last update to the play store and services 2 days ago, none of my new builds work. They all crash as soon as my app calls the plugin to register.

com.adobe.phonegap.push.PushPlugin$1.run
java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
PushPlugin.java, line 73

@vcenturion

+1

@iwc
iwc commented May 20, 2016

+1

@ppark482
ppark482 commented May 20, 2016 edited

+1

10+ build crashes with this same error

@RobertCoop

+1

@kevboutin

+1

@Jojr
Jojr commented May 20, 2016

+1

@Jojr
Jojr commented May 21, 2016

That's solution used by @zimski

I fixed the issue by removing the support of v4 in app/platforms/android/project.properties
Line to remove

cordova.system.library.2=com.android.support:support-v4:+

this file in my case already contains an other version of support

cordova.system.library.3=com.android.support:support-v13:23+

I think the v4 is deprecated for the latest version of service-gcm
The app starts correctly and the register is OK.

If some one can help and explain to me how the project.properties is generated/update ? this will allow us to fix this issue in a cleaner way.

Refer to this issue:
#911 (comment)

@macdonst
Member

Geez, a guy goes away to the PhoneGap Day conference and Google updates everything on him. I'll look at this ASAP. However, this plugin uses "com.android.support:support-v13:23+" so the "com.android.support:support-v4:+" must be being included from another package. So, if you folks can help me with a reproduction scenario like what version of android, what version of cordova-android and what plugins you have installed that would be best.

@hiperlouro

Hi!

I was having this issue with Cordova 5.2.0 and Android 4.1.1.
I tried the solution proposed by @Jojr and it worked after recreating the platforms with the support V13 only!

Anyways, here's the list of the plugins I'm using:

cordova-fabric-plugin 1.0.7 "cordova-fabric-plugin"
cordova-plugin-camera 2.1.1 "Camera"
cordova-plugin-crosswalk-webview 1.7.0 "Crosswalk WebView Engine"
cordova-plugin-datepicker 0.9.3 "DatePicker"
cordova-plugin-device 1.1.0 "Device"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.4.0 "File Transfer"
cordova-plugin-network-information 1.1.0 "Network Information"
cordova-plugin-vibration 2.0.0 "Vibration"
cordova-plugin-whitelist 1.2.0 "Whitelist"
nl.x-services.plugins.toast 2.0.4 "Toast"
phonegap-plugin-push 1.6.3 "PushPlugin"

@macdonst
Member

Working through this now. I created a fresh project, no v4 added, then I added this plugin, still no v4 added. So it is an issue with another plugin. Continuing to investigate.

@zimski
zimski commented May 22, 2016

I get the plugin that introduce the support v4

$ grep -r com.android.support plugins
plugins/phonegap-plugin-push/plugin.xml:        <framework src="com.android.support:support-v13:23+" />
plugins/cordova-plugin-mauron85-background-geolocation/plugin.xml:        <framework src="com.android.support:support-v4:+" />

So the cordova-plugin-mauron85-background-geolocation is responsible for the mess :).
You can run this command in the root of your project folder to identify the plugin

grep -r com.android.support plugins

cordova just read the plugin.xml of each plugins and add the dependency to the global project, maybe cordova need to be more smart when adding dependency and pick the recent one if several versions are found.

@macdonst
Member

@hiperlouro I went though your list of plugins and added them all to my test project except the Fabric one as I do not have a valid API key. Right now I can't reproduce the issue.

@zimski yes thanks, I see that cordova-plugin-mauron85-background-geolocation uses v4 support. In this case I don't think it is cordova that needs to be more smart it is Google. They introduced an incompatibility in their latest Play Services and previous support libraries. Trying to find the right combination that works for everyone.

@khamaileon
khamaileon commented May 22, 2016 edited

Same problem here.
Cordova 6.1.1
node 4.4.3

  "cordovaPlugins": [
    "cordova-plugin-appsettings",
    "cordova-plugin-compat",
    "cordova-plugin-console",
    "cordova-plugin-crosswalk-webview",
    "cordova-plugin-device",
    "cordova-plugin-dialogs",
    "cordova-plugin-file",
    "cordova-plugin-file-transfer",
    "cordova-plugin-network-information",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "cordova-plugin-whitelist",
    "ionic-plugin-keyboard",
    {
      "id": "phonegap-plugin-push",
      "locator": "phonegap-plugin-push",
      "variables": {
        "SENDER_ID": "XXXXXXXXXXXX"
      }
    },
    {
      "locator": "https://github.com/mnill/cordova-app-updater.git",
      "id": "com.likesmagia.cordova.updater"
    }
  ],

project.properties

target=android-23
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-crosswalk-webview/myproject-xwalk.gradle
cordova.gradle.include.2=phonegap-plugin-push/myproject-push.gradle
cordova.system.library.1=com.android.support:support-v13:23+
cordova.system.library.2=com.google.android.gms:play-services-gcm:+

It stops crashing when I stop initializing PushNotification in my JS code.

@macdonst
Member

Folks are you using the command line to build or Android Studio? I've upgraded everything for my command line builds. Currently running:

Android support repository 32
Android support library 23.2.1
Google Play Services 30
Google Repository 26

but I cannot duplicate the build error.

I'm telling Android Studio to go update everything as well but that may take a while to download so additional information to help figure this out is appreciated.

@macdonst
Member

Duplicated it.

@macdonst
Member

Yipes, this seems to be a colossal mistake by Google. Taking out any plugin that depends on v4 support seems to work but that's not a great solution. Still researching, all info and help is appreciated.

@khamaileon
khamaileon commented May 22, 2016 edited

@macdonst
I'm using the command line (ionic-cli).
I've got the same versions:

Android Support Repository 32
Android Support Library 23.2.1
Google Play services 30
Google Repository 26

and no references to support-v4

$ grep -r com.android.support plugins
plugins/phonegap-plugin-push/plugin.xml:        <framework src="com.android.support:support-v13:23+" />
@macdonst
Member

@khamaileon and you are still seeing the crash? If so can you tell me what version of Play Services is installed on your test device?

@khamaileon

If so can you tell me what version of Play Services is installed on your test device?
Where do I find it ?

@macdonst
Member

@khamaileon that's the same crash error for sure. Regarding play services. It should be in your apps section of the settings app. You may need to turn on show system apps in order to see it in the list.

@khamaileon
khamaileon commented May 22, 2016 edited

Google Play services Version 9.0.83
Android 6.0.1
Galaxy S6

@macdonst
Member

@khamaileon same as me, that leads me to believe that crosswalk includes the v4 dependency somewhere.

@khamaileon

Android support libraries (e.g. support-v4, support-v7 etc) are no longer bundled by Crosswalk and should be included explicitly if required.

@macdonst
Member

@khamaileon yup, there you go. Well spotted. So if folks are using crosswalk with the push plugin and this new GooglePlayService this will get a crash.

Still trying to find a way to work around without uninstalling plugins that need v4 support.

@crazy77
crazy77 commented May 22, 2016 edited

Thank you I removed crosswalk and app doesn't crash anymore.

@macdonst
Member

@crazy77 yeah, not a long term solution but for now we are narrowing it down.

@Jojr
Jojr commented May 22, 2016

I use the cordova-plugin-mauron85-background-geolocation

This plugin add v4 supportin plugin.xml line 65<framework src="com.android.support:support-v4:+" />
Thank's @zimski (again).

@zimski
zimski commented May 22, 2016

happy to help @Jojr :)

@macdonst
Member

@raix the problem is folks are using other plugins that do depend on v4 and that is what is causing the crash.

@macdonst
Member

Okay, I believe I have a workaround for this issue but don't have time to push changes before I get on a plane without internet for 9 hours.

In your push.gradle file add the following lines:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:23.4.0'
    }
}

and then clean and rebuild your project. That seems to be doing the trick as the incompatibility with Google Play Services 9 only happens when you have v4 version 24 or higher.

@bboybboy
bboybboy commented May 23, 2016 edited

@macdonst

Okay, I believe I have a workaround for this issue but don't have time to push changes before I get on a plane without internet for 9 hours.

In your push.gradle file add the following lines:

configurations.all { resolutionStrategy { force 'com.android.support:support-v4:23.4.0' } }

it doesn't works

@macdonst
Member

@bboybboy odd it seemed to work for me but I didn't have a lot of time to test.

@rdesimone

Just tested our apps with plugin-push and Crosswalk -> no problem. Also no v4 included. The same for older Crosswalk versions - oldest version checked is Crosswalk 13.

@hereiam133

@macdonst Just tested with your fix

In your push.gradle file add the following lines:
configurations.all { resolutionStrategy { force 'com.android.support:support-v4:23.4.0' } }

and it did the trick.

@macdonst
Member

@rdesimone well, you have to be using a new version of the v4 library 24 or higher. Crosswalk has a v4 dependency somewhere in it's dependencies. You'd only start seeing this bug if you grabbed all the new code from Google.

@hereiam133 thanks, that's good news. Once I'm done flying (sometime tomorrow) all re-test officially and release a 1.6.4 to work around the issue until Google fixes it.

@rdesimone

@macdonst thanks for replying. But I don't get it. I checked the app with push and it works fine. I run your proposed grep command grep -r com.android.support plugins - besides your plugin, nothing is listed. The phone (Nexus 6p) has all updates. Could you please explain where we will have a problem? Thanks again.

@macdonst
Member

@rdesimone check what version of the v4 support jar you have on your development machine. If it is 24 or higher you will run into the problem. Mind you it is also quite possible that Google push a fix to Play Services as well. Can't really tell, plane wifi not too great.

@rdesimone
rdesimone commented May 23, 2016 edited

@macdonst where do I have to check for v4? Under SDK tools I see Android Support Library, rev. 23.2.1. By the way I checked also with a Nexus 4 and Android 4.4. - again the push notifications (push-plugin and Crosswalk) work without any problems. I also checked the Play Services - like you I have 9.0.83 (440-12191110).

@jiankai82

@macdonst I tried your fix and it worked for me. Thanks.

@khamaileon

It works for me now and I've made no changes :-/

@gorancn
gorancn commented May 23, 2016

I've managed to "downgrade" android suport-v4 lib to 23.* version with following steps:
1.removing 24.* folders from [android-sdk-location]/extras/android/m2repository/com/android/support/support-v4
2. removing tags for 24.* versions from [android-sdk-location]/extras/android/m2repository/com/android/support/support-v4/maven-metadata.xml
3. update tag in [android-sdk-location]/extras/android/m2repository/com/android/support/support-v4/maven-metadata.xml to latest 23.* version

After these steps I've clean android build folder and build project again. It works fine after these steps.

@Marc2017

@gorancn

thanks removing the 24.* from the repo folders worked for me

I removed it from v4 and from v13.
be careful to remove all 24.* - there are multiple entries in the xml ( alpha1 and alpha2 and beta1)

seems 24.* is still in beta?

@shyamal890 shyamal890 referenced this issue in driftyco/ionic-cloud-issues May 24, 2016
Open

App crashes on push.register #106

@gion gion added a commit to Thinslices/phonegap-plugin-push that referenced this issue May 24, 2016
@gion gion Trying to fix the codeship builds
more info here: phonegap#909
1f53959
@gion
gion commented May 24, 2016

@macdonst I tried your fix and it seems to be working fine in my raw cordova app.
Thanks ๐ŸŽ‰

@macdonst macdonst removed the help wanted label May 24, 2016
@macdonst
Member

Okay I pushed out a 1.6.4 version that includes the work around. I will keep an eye on Google for the real fix.

@macdonst macdonst closed this May 24, 2016
@rdesimone

@macdonst just added the new plugin and tried to build:

Error:Failed to resolve: com.android.support:support-v4:23.4.0

Was this the reason why I didn't have the problem? (most stupid question). OK, what do I have to do? Install 1.6.3 or install a different support library?

@macdonst
Member

@rdesimone You need to download that library into your local Android support libs using the SDK tools. Sorry about the inconvenience but better that pain then a crash.

@rdesimone

@macdonst no problem, does this library come with the Android Support Repository 32? I don't see anything else I can install. Thanks for your help.

@macdonst
Member

@rdesimone you may have to downgrade to 30. See @gorancn comment above.

@rdesimone

@macdonst now I am confused. Actually I am on 30 and as commented before I did not have any crash in conjunction with Crosswalk. But now it is not possible to build with the 1.6.4 plugin because of the missing com.android.support:support-v4:23.4.0. Shall I update the library or stay with 1.6.3? What about the future when you update the plugin? Make your thoughts - I think we have a little bit a mess.

@macdonst
Member

@rdesimone downgrade to 1.6.3 but the problem you may run into in production is the app crashes because the phone has updated Google Play Services. Yes, this is a mess, a mess of Google's doing. They really need to fix this.

@rdesimone
rdesimone commented May 24, 2016 edited

@macdonst OK, we have to nail it finally. From what I understand, the recommendation should be (even though there is no crash actually):

  1. update Android Support Repository to 32 to get com.android.support:support-v4:23.4.0
  2. install 1.6.4 plugin which fixes the problem with 4:23.4.0

Is this correct?

@vhmolinar

After downloading Android Api Level updates of name rev. 3 (or something like that) the build has back working. Thanks.

@ernstdevries

I got android support repository 32 , but where do i find 1.6.4 plugin is this phonegap push plugin version 1.6.4? Because now i still get this error Error:Failed to resolve: com.android.support:support-v4:23.4.0

@srkgupta
srkgupta commented Jun 11, 2016 edited

Upgrading to the latest packages and cleaning up the existing android platform helped me resolved this issue.

Google Play Services -> Rev. 30
Android Support Repository -> Rev. 32
Google Repository -> Rev. 28
Android SDK Tools -> Rev. 25.1.7

This is how I did. Open Android SDK Manager and check for any updates required for any of the packages. If so, update all of them.

Then in your project's directory, go to /platforms/android/cordova/ and run the command ./clean

Recompile the android package and the issue is resolved.

@macdonst macdonst added a commit that referenced this issue Jun 16, 2016
@macdonst macdonst Revert Issue #909 as Google has fixed Play Services
https://developers.google.com/android/guides/releases

Google Play services updated to 9.0.1
The Google Play services version 9.0.1 release is now available. This release fixes the following issues with the version 9.0.0 release:

Fixes a class change compilation error with ContextCompat.getNoBackupFilesDir().
fe3dee5
@jcesarmobile jcesarmobile added a commit to jcesarmobile/phonegap-plugin-push that referenced this issue Jun 20, 2016
@macdonst @jcesarmobile macdonst + jcesarmobile Revert Issue #909 as Google has fixed Play Services
https://developers.google.com/android/guides/releases

Google Play services updated to 9.0.1
The Google Play services version 9.0.1 release is now available. This release fixes the following issues with the version 9.0.0 release:

Fixes a class change compilation error with ContextCompat.getNoBackupFilesDir().
cb50807
@nocodedweb

App started crashing today after I installed Android library updates. The only thing I could do to fix was to uninstall and reinstall the phonegap-plugin-push plugin and it worked like a charm.

@macdonst
Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment