AdMob and Analytics does not compile together


#1

Hi:

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 (pick one of them - they will output the same):

  1. https://github.com/appfeel/admob-google-cordova
  2. https://github.com/floatinghotpot/cordova-admob-pro

And ngCordova for google analytics
http://ngcordova.com/docs/plugins/googleAnalytics/

combined together they give this error:
(Please tell me how to resolve this like I am two year old :slight_smile: 10x in advance)

: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)


#2

Does anyone have a solution to this? I ran into this exact same issue, I first installed admob and then installed GA and got this error. I have read that it has to due with multiple com.android.support references in the build gradle but i’m not sure how to resolve that in ionic.


#3

Same here, when I used Eclipse, I could build and run these plugins just fine, but after I changed to Android Studio, I just can’t build with AdMob and Analytics plugins together, and Facebook plugin is very problematic too.

It has been a while that Gradle is driving people mad. There are some reports on this issue in StackOverflow, but none of them really helped solve it. I don’t know if Gradle has changed something along the way, but it feels like it did.

Does anyone have a clue on this?


#4

Please check out my guide on youtube and maybe help to solve your problem

  1. About Google Analytics
    https://www.youtube.com/watch?v=LrJWH_lcALQ
  2. About Admob
    https://www.youtube.com/watch?v=KBYV_9q6P-E

#5

10x. surrely check it out