今天我更新了 SDK 工具,之后因为这个错误我无法构建我的应用程序:
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
这是来源:
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 */ }
}
我正在使用 GoogleAdMobAdsSdk-6.4.1.jar 版本。如果我从 libs 文件夹中删除 jar 文件,则构建成功。我尝试将 sdk 工具降级到 20.0.3,但这并没有解决我的问题,而是通过更新 :(