public final class DxDexArchiveMerger extends java.lang.Object implements DexArchiveMerger
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
mergeDexArchives(Iterable, Path, Path, DexingType) 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.
| Constructor and Description |
|---|
DxDexArchiveMerger(com.android.dx.command.dexer.DxContext dxContext,
DexMergingStrategy mergingStrategy,
java.util.concurrent.ForkJoinPool forkJoinPool) |
DxDexArchiveMerger(com.android.dx.command.dexer.DxContext dxContext,
java.util.concurrent.ForkJoinPool forkJoinPool)
Creates an instance of merger.
|
| Modifier and Type | Method and Description |
|---|---|
void |
mergeDexArchives(java.lang.Iterable<java.nio.file.Path> inputs,
java.nio.file.Path outputDir,
java.nio.file.Path mainDexClasses,
DexingType dexingType)
Triggers the actual merging by processing all DEX files from dex archives, and outputting the
DEX file(s) in the specified directory.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateD8DexMerger, createDxDexMergerpublic DxDexArchiveMerger(@NonNull
com.android.dx.command.dexer.DxContext dxContext,
@NonNull
java.util.concurrent.ForkJoinPool forkJoinPool)
mergeDexArchives(Iterable, Path, Path, DexingType) 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.dxContext - dx context necessary for the merging processforkJoinPool - executor used to schedule tasks in the merging processpublic DxDexArchiveMerger(@NonNull
com.android.dx.command.dexer.DxContext dxContext,
@NonNull
DexMergingStrategy mergingStrategy,
@NonNull
java.util.concurrent.ForkJoinPool forkJoinPool)
public void mergeDexArchives(@NonNull
java.lang.Iterable<java.nio.file.Path> inputs,
@NonNull
java.nio.file.Path outputDir,
@Nullable
java.nio.file.Path mainDexClasses,
@NonNull
DexingType dexingType)
throws DexArchiveMergerException
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, 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.
mergeDexArchives in interface DexArchiveMergerinputs - paths to the dex archives that should be mergedoutputDir - directory where merged dex file(s) will be written, must existmainDexClasses - file containing list of classes to be merged in the main dex filedexingType - specifies how to merge dex filesDexArchiveMergerException