16

I created android application and try to add admob to it. but it not works. can anyone help me to fix this error.

[2014-04-09 15:16:51 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;
[2014-04-09 15:16:51 - Aurudhu_App] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode;

This is the application architecture.

enter image description here

anuruddhika
  • 1,549
  • 8
  • 26
  • 40

12 Answers12

22

google-pay-services.jar and GoogleAdMobAdsSdk.jar having same class name for AdMob. May be due to that reason you are getting multiple .dex files.

Please follow the docs steps of this sample code link of AdMob by using google-pay-services.jar instead of GoogleAdMobAdsSdk.jar.

Hope it will help you, Still you have any problem then let me know...

Vishesh Chandra
  • 6,951
  • 6
  • 35
  • 38
7

I had this error.

Make sure google-play-service.jar is not added twice (even in different modules...as in my case). It takes long time to debug those bugs.

KVISH
  • 12,923
  • 17
  • 86
  • 162
  • I voted this one up because it is referring to a issue I had. However it takes some tricks to delete the multiple jar files. What I did is uncheck the play-service in eclipse-properties, then close eclipse, delete the jar file (which is duplicate) and back to eclipse, properties and add the library again. After a while that did my trick. But thanks for the direction.. – Riverside Aug 29 '14 at 22:20
4

Eclipse project properties->Java build path->Order and export

Un-check Android private libraries.

Akanksha Rathore
  • 3,603
  • 3
  • 31
  • 47
3

You have imported google-play-services and used as library. you've also added google-play-services external jar files. So ambiguity. Do not use google-play-services as library.

Amareshwar Bhat
  • 139
  • 1
  • 7
2

I encountered this problem after adding google-play-services, but it was on a project that was not using the sdk for AdMob. After doing a clean rebuild, I stopped receiving this error. So if you are experiencing this, but are not using AdMob or still cannot figure it out for whatever reason, try doing a project clean rebuild. That is what worked for me.

Dave
  • 1,250
  • 1
  • 16
  • 32
1

I had this problem because I had the google-play-services.jar in my libs folder, while including the play services in build.gradle like this:

dependencies {
  ...
  compile 'com.google.android.gms:play-services:5.0.89'
  ...
}

So I deleted the google-play-services.jar from the libs folder and the app was working fine again

fknChaos
  • 113
  • 1
  • 3
  • 11
0

I had this problem, and this problem too:

java.lang.NoClassDefFoundError: com.google.ads.AdView

Despite many hours of following all solutions listed the only way I could get my app to work was to use the AdMob banner example here.

And re-build my project around it, copying my files in to that project. If you are stuck, try it.

Don't know why it worked, but now it does. Something in my project was very wrong. Now I can carry on with my work. I love Google/Android, but really what a mess!

Community
  • 1
  • 1
0

select project Rigth click on project--> Build Path --> Configure Build path--> Select libraries-->uncheck googleplaylib, and clean. and run, i hope it will work, I can solve my problem using this method. Try

Suhad Bin Zubair
  • 717
  • 7
  • 10
0

Remove google play service plugin by writing cordova plugin remove com.google.playservices and add the cordova admob plugin by writing cordova plugin add [your admob plugin name] .

Ab Pati
  • 27
  • 6
0

Go to Eclipse, Project -> Build ALL

Fixed the problem for me. I do not have Admob lib added, but got that issue. Cleaning build and BUILDING ALL fixed it for me.

itzo
  • 1,220
  • 14
  • 18
0

In my case the problem occured when i moved to firebase.

The problem dissappeared when removing old "GoogleAdMobAdsSdk" sdk from "app\libs" folder.

cahit beyaz
  • 4,829
  • 1
  • 30
  • 25
0

just go to propertise by clicking alt+enter then go to java build path . then uncheck the private dependency the magic happens and your er