0

I am working on a professionel project with Ionic 2. I have the presentation with clients coming monday (24/04/2017). Unfortunately from last Friday i am facing a conflict with cordova plugins. The application works well with IOS but build fails with Android. I think the conflict comes with :

  • cordova-plugin-mauron85-background-geolocation "CDVBackgroundGeolocation"
  • cordova-plugin-fcm "FCMPlugin"

At the beggining i had a version conflict, so i changed the version into cordova-plugin-mauron85-background-geolocation with framework src="com.google.android.gms:play-services-location:9.0.0". The error was :

Found com.google.android.gms:play-services-location:+, but version 9.0.0 is needed for the google-services plugin.
:processDebugGoogleServices FAILED 

After solved the version conflict, now i am facing a new problem. The problem is:

: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/common/api/zza;

And as i have always in my console the following message, i have tried to fix it manually. I tried to apply some solutions that i have found by searches.

The message in console is :

google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
please apply google-services plugin at the bottom of the build file.

The manual fix was adding the following lines in my platforms/android/build.graddle (in correct places):

  • classpath 'com.google.gms:google-services:3.0.0' (in classpath dependencies)
  • apply plugin: 'com.google.gms.google-services' (at the bottom of the file)

But i got the following error with this modification, so i deleted them :

>FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
Cannot add task ':processDebugGoogleServices' as a task with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output: 
FAILURE: Build failed with an exception.

My platforms/android/project.properties :

target=android-24
android.library.reference.1=CordovaLib
cordova.gradle.include.1=cordova-plugin-fcm/myProjectV2-FCMPlugin.gradle
cordova.gradle.include.2=cordova-plugin-mauron85-background-geolocation/myProjectV2-logtofile.gradle
cordova.system.library.3=com.google.android.gms:play-services-location:9.0.0
cordova.system.library.4=com.android.support:support-v4:+

Hope that i will get some help. Thanks.

  • when asking questions about build problems you should include stack traces or debug logs with your question. Also i would like to note that in a professional project it is not recommended and even against best practice to not specify your dependency version for this very reason. Without specifying those projects can update and break everything without your knowledge. Please add the necessary lines to gradle for google-services again and then run your build with --stacktrace or --debug look through it and post related results. Should be something like `./gradlew assembleDebug --stacktrace` – doubleA Apr 18 '17 at 21:51
  • Thank you for your note on dependency. I paste my output of gradlew assembleDebug --stacktrace in this link http://pastebin.fr/49855 Thanks – JP RabbouniCha Apr 19 '17 at 09:07
  • 1
    This looks like a dependency issue. `Caused by: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza;` look that up a bit and see if anything works for you and build.gradle files would be useful here. Please post your app and module gradle files when you get a chance. Also for the sake of posting good questions please post a single block of that stack trace from your pastebin that includes the line i mentioned above. This gives future readers context without having to search through comments. – doubleA Apr 19 '17 at 15:58
  • 2
    @doubleA Thank you for your reply. I found the solution by changing the versions of my dependencies into platforms/android/project.properties There is a conflict when we use fcm and background geolication in a project. So we need to change the version of one plugin. It is well explained here https://github.com/fechanique/cordova-plugin-fcm/issues/53 Also i uninstalled google service plugin from the project. – JP RabbouniCha Apr 23 '17 at 12:19
  • Glad i could help. Post your answer if you think it might help someone. Good to hear you found the solution i know those issues are difficult to track down. Happy coding. – doubleA Apr 26 '17 at 21:23

0 Answers0