コード例 #1
0
  /** Generates a dex file and returns its bytes. */
  public byte[] generate() {
    DexOptions options = new DexOptions();
    options.targetApiLevel = DexFormat.API_NO_EXTENDED_OPCODES;
    DexFile outputDex = new DexFile(options);

    for (TypeDeclaration typeDeclaration : types.values()) {
      outputDex.add(typeDeclaration.toClassDefItem());
    }

    try {
      return outputDex.toDex(null, false);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }