2

I am trying to implement AdMob and Analytics on the same app together. The thing is separately they work but on the same app they have errors.

For AdMob I used, separately, (1) and (2).

But, when I tried using (1) and (3) or (2) and (3), combined together they give this error:

:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/google/ads/AdReques
t$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:45
4)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

FAILED

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Program Files (x86)\Android\android-sdk\build-tools\22.0.1\dx.bat --d
ex --no-optimize --output C:\a\0\testAdsGA\platforms\android\build\intermediates
\dex\debug --input-list=C:\a\0\testAdsGA\platforms\android\build\intermediates\t
mp\dex\debug\inputList.txt
Error Code:
2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/google/ads/
AdRequest$ErrorCode;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.ja
va:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:
554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:
535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)

            at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
            at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main
.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Rodmentou
  • 1,610
  • 3
  • 21
  • 39
helenakohan
  • 423
  • 1
  • 4
  • 4
  • 1: http://stackoverflow.com/questions/27561153/errorexecution-failed-for-task-appdexdebug 2: http://stackoverflow.com/questions/18021901/android-studio-gradle-build-fails-execution-failed-for-task-dexdebug 3: http://stackoverflow.com/questions/27675717/gradle-error-execution-failed-for-task-appdexdebug 4: http://stackoverflow.com/questions/21102598/android-studio-unexpected-top-level-exception it is a common error, don't know a ton about gradle or the build process but it seems to be a problem with jar files not compiling or including the same android services more than once – Jess Patton Jul 01 '15 at 14:50
  • See the FAQ: https://github.com/floatinghotpot/cordova-admob-pro/wiki/Difference-of-Plugin-IDs#3-build-error-with-message-multiple-dex-files-define-lcomgoogle – Raymond Xie Jul 03 '15 at 13:35

1 Answers1

0

I'm the author of the admob-google-cordova at https://github.com/appfeel/admob-google-cordova.

Have you tried using it with our analytics plugin at https://github.com/appfeel/analytics-google?

Miquel
  • 8,339
  • 11
  • 59
  • 82
  • Hi: 10x.(dd not expect you:) ) I tried it but when I use Real-Time it does not show any tracking (active users is 0 and the graph wont change). The admob plugin should be generic and work well with other plugins in my opinion. Specially if it is ngCordova. Google Analytics uses Play Services 7.5 right now. – helenakohan Jul 03 '15 at 08:23
  • :) Well in fact our admob plugin is not in ngCordova (maybe soon...). However it supports Ionic and for sure it uses 7.5 anyway. Just to make sure, did you tried the analytics in a real device? It won't work in navigators as it is native plugin. Also have you tried to [change dispatch period](https://github.com/appfeel/analytics-google#setdispatchperiodperiod-success-error)?. The last thing, could you try [debug mode](https://github.com/appfeel/analytics-google#setdebugmodesuccess-error) and paste the log? – Miquel Jul 06 '15 at 08:13