Java – multiple DEX file definitions / buildconfig, unable to find reason:

I am using the new graduate building system and I am facing the following problems:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/kibo/mobi/BuildConfig;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

I can't see anything about dependencies. Here is:

firstDebugCompile - ## Internal use,do not manually configure ##
 \--- KiboGradle:KiboSDK:unspecified
 +--- KiboGradle:TextInputAPI:unspecified
 +--- KiboGradle:VoiceImeUtils:unspecified
 +--- com.google.android.gms:play-services:5.0.77
 |    \--- com.android.support:support-v4:19.1.0
 +--- com.squareup.picasso:picasso:2.3.2
 +--- com.google.code.gson:gson:2.2.4
 \--- com.crittercism:crittercism-android-agent:4.5.1

I tried to verify that the problem is not a duplicate support library, so I tried to add:

compile ('com.google.android.gms:play-services:5.0.77'){
    exclude module: 'support-v4'
}

What causes some errors that support - V4 library classes not to be found, so this library cannot be compiled from any other location

One thing that occurred to me was the fact that I used flavors featre in oreder to create files of different versions of my application

When I see the file in the error, I see:

**
* Automatically generated file. DO NOT MODIFY
*/
package com.kibo.mobi;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String PACKAGE_NAME = "com.kibo.mobi.test.official";
  public static final String BUILD_TYPE = "debug";
  public static final String FLAVOR = "liverpool";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0";
}

Therefore, the file in the package is different from the string value specified in the package

Can anyone see any problems in my configuration that may cause this problem?

Solution

In my case, a similar error occurred because of the Android manifest There are two modules with the same package name in the XML file Using different package names in the module solves the problem

The same thing happens when a library jar is contained twice (or more) in several modules as dependencies In this case, the error message indicates a duplicate configuration after the package name of the library I solved it, taking the library as a dependency in a module, and the second module depends on the first module

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>