public class DexArchiveMerger
extends java.lang.Object
DexArchives, and produces the final DEX file(s). Inputs can
come from one or more dex archives. In order to process the dex archives, one should invoke
merge(Collection, Path, Set) method.
In order to merge individual DEX files, we are using DexMergingStrategy to determine
how many input DEX files can fit into a single output DEX.
Merging is actually executed by invoking the DexMerger, which is part of dx.
| Modifier and Type | Class and Description |
|---|---|
static class |
DexArchiveMerger.DexArchiveMergerException
Exception thrown when dex archive merging goes wrong.
|
| Constructor and Description |
|---|
DexArchiveMerger(DexMergerConfig config,
DexMergingStrategy mergingStrategy,
java.util.concurrent.ForkJoinPool forkJoinPool) |
DexArchiveMerger(DexMergerConfig config,
java.util.concurrent.ForkJoinPool forkJoinPool)
Creates an instance of merger.
|
| Modifier and Type | Method and Description |
|---|---|
void |
merge(java.util.Collection<java.nio.file.Path> inputs,
java.nio.file.Path outputDir,
java.util.Set<java.lang.String> mainDexClasses)
Triggers the actual merging by processing all DEX files from dex archives, and outputting the
DEX file(s) in the specified directory.
|
public DexArchiveMerger(@NonNull
DexMergerConfig config,
@NonNull
java.util.concurrent.ForkJoinPool forkJoinPool)
merge(Collection, Path, Set) method, might return before final DEX file(s) are merged and
written out. Therefore, the invoker will have to block on the executor, in order to be sure
the merging is finished.config - configuration for this mergingforkJoinPool - executor used to schedule tasks in the merging processpublic DexArchiveMerger(@NonNull
DexMergerConfig config,
@NonNull
DexMergingStrategy mergingStrategy,
@NonNull
java.util.concurrent.ForkJoinPool forkJoinPool)
public void merge(@NonNull
java.util.Collection<java.nio.file.Path> inputs,
@NonNull
java.nio.file.Path outputDir,
@Nullable
java.util.Set<java.lang.String> mainDexClasses)
throws java.io.IOException
In case of mono-dex, it is expected that all DEX files will fit into a single output DEX
file. If this is not possible, DexIndexOverflowException exception will be thrown.
When merging native multidex, multiple DEX files might be created.
In case of legacy multidex, list of classes in the main dex should be specified as well. When using legacy multidex mode, only classes explicitly specified in this list will be in the main dex file. This is equivalent of invoking dx with --minimal-main-dex option.
java.io.IOException