Interface DexArchiveMerger


public interface DexArchiveMerger
A dex archive merger that can merge dex files from multiple dex archives into one or more dex files.
  • Method Summary

    Modifier and Type
    Method
    Description
    createD8DexMerger(com.android.ide.common.blame.MessageReceiver messageReceiver, com.android.builder.dexing.DexingType dexingType, int minSdkVersion, boolean isDebuggable, ForkJoinPool forkJoinPool)
    Creates an instance of dex archive merger that is using d8 to merge dex files.
    void
    mergeDexArchives(List<DexArchiveEntry> dexArchiveEntries, List<Path> globalSynthetics, Path outputDir, List<Path> mainDexRulesFiles, List<String> mainDexRules, Path userMultidexKeepFile, Collection<Path> libraryFiles, Path inputProfileForDexStartupOptimization, Path mainDexListOutput)
    Merges the specified dex archive entries into one or more dex files under the specified directory.
  • Method Details

    • createD8DexMerger

      @NonNull static DexArchiveMerger createD8DexMerger(@NonNull com.android.ide.common.blame.MessageReceiver messageReceiver, @NonNull com.android.builder.dexing.DexingType dexingType, int minSdkVersion, boolean isDebuggable, @Nullable ForkJoinPool forkJoinPool)
      Creates an instance of dex archive merger that is using d8 to merge dex files.
    • mergeDexArchives

      void mergeDexArchives(@NonNull List<DexArchiveEntry> dexArchiveEntries, @NonNull List<Path> globalSynthetics, @NonNull Path outputDir, @Nullable List<Path> mainDexRulesFiles, @Nullable List<String> mainDexRules, @Nullable Path userMultidexKeepFile, @Nullable Collection<Path> libraryFiles, @Nullable Path inputProfileForDexStartupOptimization, @Nullable Path mainDexListOutput) throws DexArchiveMergerException, IOException
      Merges the specified dex archive entries into one or more dex files under the specified directory.

      Dexing type specifies how files will be merged:

      • if it is DexingType.MONO_DEX, a single dex file is written, named classes.dex
      • if it is DexingType.LEGACY_MULTIDEX, there can be more than 1 dex files. Files are named classes.dex, classes2.dex, classes3.dex etc. In this mode, path to a file containing the list of classes to be placed in the main dex file must be specified.
      • if it is DexingType.NATIVE_MULTIDEX, there can be 1 or more dex files.
      Parameters:
      dexArchiveEntries - the dex archive entries to merge
      outputDir - directory where merged dex file(s) will be written, must exist
      globalSynthetics - the global synthetics files to be merged with or without dex archive entries
      mainDexRulesFiles - files containing the Proguard rules
      mainDexRules - Proguard rules written as strings
      userMultidexKeepFile - a user specified file containing classes to be kept in the main dex list
      libraryFiles - classes that are used only to resolve types in the program classes, but are not packaged in the final binary e.g. android.jar, provided classes etc.
      mainDexListOutput - the output location of classes to be kept in the main dex file
      inputProfileForDexStartupOptimization - the merged startup profile that is used to optimize the dex in D8 when present
      Throws:
      DexArchiveMergerException
      IOException