Pregunta

Today i updated the SDK tools and after that i can't build my app because of this error:

Error:Android Dex: [App] UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Android Dex: [App] java.lang.IllegalArgumentException: already added: Lcom/google/ads/AdRequest$ErrorCode;
Error:Android Dex: [App] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
Error:Android Dex: [App] at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processClass(Main.java:685)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.access$600(Main.java:78)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
Error:Android Dex: [App] at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
Error:Android Dex: [App] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
Error:Android Dex: [App] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processOne(Main.java:596)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
Error:Android Dex: [App] at com.android.dx.command.dexer.Main.run(Main.java:230)
Error:Android Dex: [App] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [App] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Error:Android Dex: [App] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Error:Android Dex: [App] at java.lang.reflect.Method.invoke(Method.java:606)
Error:Android Dex: [App] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:139)
Error:Android Dex: [App] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:261)
Error:Android Dex: [App] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)
Error:Android Dex: [App] 1 error; aborting

this is the source:

public static enum ErrorCode {
    INVALID_REQUEST, NO_FILL, NETWORK_ERROR, INTERNAL_ERROR;

    private final java.lang.String a;

    public static com.google.ads.AdRequest.ErrorCode[] values() { /* compiled code */ }

    public static com.google.ads.AdRequest.ErrorCode valueOf(java.lang.String name) { /* compiled code */ }

    private ErrorCode(java.lang.String description) { /* compiled code */ }

    public java.lang.String toString() { /* compiled code */ }
}

I'm using GoogleAdMobAdsSdk-6.4.1.jar version. If i remove the jar file from the libs folder the build is success. I tried downgrade the sdk tools to 20.0.3, but it wasn't solve my problem, but came it with update :(

¿Fue útil?

Solución

I found the solution: i didn't recognize that i updated the google play service too automaticly from v12 to v13. And in the new version of google-play-services.jar include a new ErrorCode class like the GoogleAdMobAdsSdk-6.4.1.jar. So i downgrade the google play service lib from this site http://venomvendor.blogspot.co.il/2012/03/android-sdk-extras-by-google-inc.html and it solved my problem.

Otros consejos

You are correct in that it is caused by having both Admob-6.4.1 and the latest Google play Services in your classpath when building.

The latest GPS now contains the Admob classes (note that there are also updated version of the Admob classes in a new package - which is what you should use from now on).

The best solution here is to use the latest Google play Services library and ditch Admob 6.4.1

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top