Android 多个 dex 文件定义 Lcom/google/ads/AdRequest$ErrorCode 和多个 dex 文件定义 Lcom/google/ads/AdRequest$ErrorCode
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22958979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode and Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode
提问by anuruddhika
I created android application and try to add admob to it. but it not works. can anyone help me to fix this error.
我创建了 android 应用程序并尝试向其中添加 admob。但它不起作用。谁能帮我解决这个错误。
[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.
这就是应用程序架构。
回答by vishesh chandra
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.
google-pay-services.jar 和 GoogleAdMobAdsSdk.jar 具有相同的 AdMob 类名。可能是因为这个原因,你得到了多个 .dex 文件。
Please follow the docs steps of this sample code linkof AdMob by using google-pay-services.jar instead of GoogleAdMobAdsSdk.jar.
请按照此AdMob示例代码链接的文档步骤使用 google-pay-services.jar 而不是 GoogleAdMobAdsSdk.jar。
Hope it will help you, Still you have any problem then let me know...
希望它会帮助你,如果你有任何问题,请告诉我......
回答by KVISH
I had this error.
我有这个错误。
Make sure google-play-service.jar is notadded twice (even in different modules...as in my case). It takes long time to debug those bugs.
确保 google-play-service.jar没有添加两次(即使在不同的模块中......就像我的情况一样)。调试这些错误需要很长时间。
回答by Akanksha Rathore
Eclipse project properties->Java build path->Order and export
Eclipse 项目属性->Java 构建路径->订购和导出
Un-check Android private libraries.
取消选中 Android 私有库。
回答by Amareshwar Bhat
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.
您已导入 google-play-services 并用作库。您还添加了 google-play-services 外部 jar 文件。那么暧昧。不要使用 google-play-services 作为库。
回答by Dave
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.
我在添加 google-play-services 后遇到了这个问题,但它是在一个没有使用 AdMob sdk 的项目上。进行干净的重建后,我不再收到此错误。因此,如果您遇到了这种情况,但没有使用 AdMob 或出于某种原因仍然无法弄清楚,请尝试进行项目清理重建。这对我有用。
回答by fknChaos
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:
我遇到了这个问题,因为我的 libs 文件夹中有 google-play-services.jar,同时在 build.gradle 中包含播放服务,如下所示:
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
所以我从 libs 文件夹中删除了 google-play-services.jar 并且该应用程序再次正常工作
回答by Suhad Bin Zubair
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
选择项目右键单击项目--> 构建路径--> 配置构建路径--> 选择库--> 取消选中googleplaylib,然后清理。并运行,我希望它会起作用,我可以使用这种方法解决我的问题。尝试
回答by user3725725
I had this problem, and this problem too:
我有这个问题,也有这个问题:
java.lang.NoClassDefFoundError: com.google.ads.AdView
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.
尽管遵循列出的所有解决方案花费了很多时间,但我可以让我的应用程序正常工作的唯一方法是使用此处的AdMob banner
示例。
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!
不知道为什么它起作用,但现在它起作用了。我的项目中有些东西非常错误。现在我可以继续我的工作了。我爱Google/Android
,但真的是一团糟!
回答by Ab Pati
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] .
通过编写 cordova plugin remove com.google.playservices 删除 google play service plugin 并通过编写 cordova plugin add [your admob plugin name] 添加cordova admob插件。
回答by itzo
Go to Eclipse, Project -> Build ALL
转到 Eclipse,项目 -> 全部构建
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.
为我解决了问题。我没有添加 Admob lib,但遇到了这个问题。清理构建和构建 ALL 为我修复了它。