Interface DexArchive

All Superinterfaces:
AutoCloseable, Closeable

public interface DexArchive extends Closeable
Interface describing the DEX archive. It contains one DEX file per .class file that was processed i.e. each DEX file in it, contains definition of exactly one class. Also, the directory structure is preserved e.g. if a file com/example/tools/A.class was processed, it will have relative path com/example/tools/A.dex in the archive.

Dex archives can be updated by adding new files.

When using instances of DexArchive make sure that you invoke Closeable.close() after you are done using it.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFile(String relativePath, byte[] bytes, int offset, int end)
    Adds a DEX file to this dex archive from a byte[].
    Returns the path to this DEX archive.
    Returns all dex archive entries in this dex archive.

    Methods inherited from interface java.io.Closeable

    close
  • Method Details

    • getRootPath

      @NonNull Path getRootPath()
      Returns the path to this DEX archive.
      Returns:
      path to this archive
    • addFile

      void addFile(@NonNull String relativePath, byte[] bytes, int offset, int end) throws IOException
      Adds a DEX file to this dex archive from a byte[]. Adding is performed relative to the getRootPath(). In case file with the same relative path already exists, implementations of this method should overwrite it with the new version of the file.
      Parameters:
      relativePath - file to be added to this archive
      bytes - the buffer to get the dex file content from
      offset - the offset for the buffer window.
      end - the end of the buffer window.
      Throws:
      IOException - if the dex file cannot be written.
    • getSortedDexArchiveEntries

      @NonNull List<DexArchiveEntry> getSortedDexArchiveEntries()
      Returns all dex archive entries in this dex archive.

      The dex archive entries are sorted to ensure deterministic order.