Pushwoosh / pushwoosh-phonegap-plugin

Pushwoosh PhoneGap Build Plugin
Other
110 stars 139 forks source link

"Some input files use or override a deprecated API" - Google Mobile Services (GMS) 11.4.0 clash with Background Geolocation #264

Closed kelvindart closed 6 years ago

kelvindart commented 7 years ago

Your Environment

Expected Behavior

For the plugin to build regardless of the GMS services specified.

Actual Behavior

There is a clash when using this plugin in combination with Background Geolocation.

I am aware this is not a specific plugin problem, and I do not know who is correct. However, I am raising a bug to both plugin developers, in order to gain the knowledge.

There has been an update to Google Mobile Services (GMS) which is now at 11.4.0: https://developers.google.com/android/guides/releases. In the Background Geolocation's project's build.gradle, there is a loose version of com.google.android.gms:play-services-location:11.+ specified, so naturally the project will try to compile using the latest version available, 11.4.0 in this instance.

However, PushWoosh explicitly set their required version to 11.2.0: https://github.com/Pushwoosh/pushwoosh-phonegap-plugin/blob/d374af1c92e3b9cb15e444f580906d311633eedf/plugin.xml#L254

This then results in a build error when trying to execute the Gradle task transformClassesWithDexForDebug:

Error: /Users/kelvindart/src/MyApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzcaf;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I am unsure whether there is a config setting I can pass to set this. Is this possible?

Workaround The workaround at the moment is to navigate to {project}-build.gradle, and modify the following line:

compile 'com.google.android.gms:play-services-location:11.+'

to:

compile 'com.google.android.gms:play-services-location:11.2.0'

Steps to Reproduce

  1. Create an empty Cordova project: cordova create MyApp && cd MyApp
  2. Add the Android platform: cordova platform add android
  3. Add the PushWoosh plugin: cordova plugin add pushwoosh-cordova-plugin@7.0.7
  4. Add the Background Geolocation plugin: cordova plugin add cordova-background-geolocation-lt@2.8.5
  5. Build the project: cordova build android
  6. Observe the error.

Context

As above.

Debug logs

A screenshot of my Android SDK installation is as follows: t

:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzcaf;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.742 secs
Command finished with error code 1: /Users/kelvindart/src/MyApp/platforms/android/gradlew cdvBuildDebug,-b,/Users/kelvindart/src/MyApp/platforms/android/build.gradle,-Dorg.gradle.daemon=true,-Dorg.gradle.jvmargs=-Xmx2048m,-Pandroid.useDeprecatedNdk=true
Error: /Users/kelvindart/src/MyApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzcaf;

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    at ChildProcess.whenDone (/Users/kelvindart/src/MyApp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:921:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
wfhm commented 7 years ago

Hi,

There is no strict requirement on using 'com.google.android.gms:play-services-gcm:11.2.0'. You can change it with 'com.google.android.gms:play-services-gcm:11.+' to solve this conflict.

pugwonk commented 6 years ago

I have this same error having just updated the plugin to 7.0.7 (and I also use the background geolocation plugin, albeit it from cordova-plugin-mauron85-background-geolocation). However, if I remove both of those plugins the build still fails, and changing the gradle files didn't seem to do anything. I'm guessing something else broke, but just FYI!

pugwonk commented 6 years ago

I got this working by editing plugins/pushwoosh-cordova-plugin/plugin.xml. In the various lines that specified 11.2.0, I changed them to 11.+. E.g.:

<framework src="com.google.android.gms:play-services-location:11.+" />

I then removed and re-added the plugin, and everything compiles. I haven't actually checked whether it works but from what wfhm said I suspect it does.

In case anyone else hits this, my other issue seemed to be related to cordova-plugin-compat. Removing it and re-adding it fixed it.