private byte[] mergeLibraryDexBuffers(byte[] outArray) throws IOException {
    ArrayList<Dex> dexes = new ArrayList<Dex>();
    if (outArray != null) {
      dexes.add(new Dex(outArray));
    }
    for (byte[] libraryDex : libraryDexBuffers) {
      dexes.add(new Dex(libraryDex));
    }
    if (dexes.isEmpty()) {
      return null;
    }
    Dex merged =
        new DexMerger(dexes.toArray(new Dex[dexes.size()]), CollisionPolicy.FAIL, context).merge();
    return merged.getBytes();
  }
Merges the dex files in library jars. If multiple dex files define the same type, this fails
with an exception.
android/android_framework/dex-maker/src/main/java/com/android/dx/command/dexer/Main.java