1

I am having the following dependencies in the build.gradle file. Note that I am using Ionic/Cordova mobile app.

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile project(path: "CordovaLib", configuration: "debug")
    releaseCompile project(path: "CordovaLib", configuration: "release")
    compile "com.google.android.gms:play-services-analytics:+"
    compile "com.onesignal:OneSignal:3.3.0@aar"
    compile "com.google.android.gms:play-services-gcm:+"
    compile "com.google.android.gms:play-services-location:+"
    compile "com.google.android.gms:play-services-ads:8.4+"
    // SUB-PROJECT DEPENDENCIES END
}

I get the below error during the build process.

Error: cmd: 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.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzah;
    UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzah;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:591)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:546)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:528)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
        at com.android.dx.command.dexer.Main.run(Main.java:277)
        at com.android.dx.command.dexer.Main.main(Main.java:245)
        at com.android.dx.command.Main.main(Main.java:106)


FAILURE: Build failed with an exception.

I read the below SO links. It says about app level and module level gradle files. I am not sure which 2 files are those.

Version conflict updating to 8.4.0

Multiple dex files define Lcom/google/android/gms/internal/zzim;

Multiple dex files define Lcom/google/android/gms/internal/zzau

Community
  • 1
  • 1
Purus
  • 5,701
  • 9
  • 50
  • 89

2 Answers2

0

That error occurs when you have the same library/directory included more than once in your build.gradle's dependencies. This looks also to be conflict with another plugin your using as stated in this thread.

You can check these links:

Check all your dependencies in your build.gradle file. Are you referencing a dependency that also includes a dependency you have already included? For example, if your including appcompat-v7 there is no need to include appcompat-v4 since v7 includes all features from v4.

This error is caused by having too many method referenced in your project. You can read more here. Generally it means that you need to remove unused libraries or use proguard even on debug build to reduce the number of method referenced. You may also go with the multi-dex approached mentioned in the article but it makes your project more complicated.

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
0

I am not sure about the reason, but adding Google Admob library plugin the build was successful.

NOTE: I am using cordova plugin for Admob.

Purus
  • 5,701
  • 9
  • 50
  • 89