com.android.dx.command.dexer.Main Java Examples
The following examples show how to use
com.android.dx.command.dexer.Main.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaToDex.java From Box with Apache License 2.0 | 6 votes |
public List<Path> convert(Path jar) throws JadxException { try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream errOut = new ByteArrayOutputStream()) { DxContext context = new DxContext(out, errOut); Path dir = FileUtils.createTempDir("jar-to-dex-"); DxArgs args = new DxArgs( context, dir.toAbsolutePath().toString(), new String[] { jar.toAbsolutePath().toString() }); int result = new Main(context).runDx(args); dxErrors = errOut.toString(CHARSET_NAME); if (result != 0) { throw new JadxException("Java to dex conversion error, code: " + result); } List<Path> list = new ArrayList<>(); try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir)) { for (Path child : ds) { list.add(child); child.toFile().deleteOnExit(); } } return list; } catch (Exception e) { throw new JadxException("dx exception: " + e.getMessage(), e); } }
Example #2
Source File: JavaToDex.java From Box with Apache License 2.0 | 6 votes |
public List<Path> convert(Path jar) throws JadxException { try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream errOut = new ByteArrayOutputStream()) { DxContext context = new DxContext(out, errOut); Path dir = FileUtils.createTempDir("jar-to-dex-"); DxArgs args = new DxArgs( context, dir.toAbsolutePath().toString(), new String[] { jar.toAbsolutePath().toString() }); int result = new Main(context).runDx(args); dxErrors = errOut.toString(CHARSET_NAME); if (result != 0) { throw new JadxException("Java to dex conversion error, code: " + result); } List<Path> list = new ArrayList<>(); try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir)) { for (Path child : ds) { list.add(child); child.toFile().deleteOnExit(); } } return list; } catch (Exception e) { throw new JadxException("dx exception: " + e.getMessage(), e); } }
Example #3
Source File: DxConverter.java From jadx with Apache License 2.0 | 6 votes |
public static void run(Path path, Path tempDirectory) { int result; String dxErrors; try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream errOut = new ByteArrayOutputStream()) { DxContext context = new DxContext(out, errOut); DxArgs args = new DxArgs( context, tempDirectory.toAbsolutePath().toString(), new String[] { path.toAbsolutePath().toString() }); result = new Main(context).runDx(args); dxErrors = errOut.toString(CHARSET_NAME); } catch (Exception e) { throw new RuntimeException("dx exception: " + e.getMessage(), e); } if (result != 0) { throw new RuntimeException("Java to dex conversion error, code: " + result + "\n errors: " + dxErrors); } }
Example #4
Source File: TypeIdsSection.java From buck with Apache License 2.0 | 6 votes |
/** * Writes the portion of the file header that refers to this instance. * * @param out {@code non-null;} where to write */ public void writeHeaderPart(AnnotatedOutput out) { throwIfNotPrepared(); int sz = typeIds.size(); int offset = (sz == 0) ? 0 : getFileOffset(); if (sz > DexFormat.MAX_TYPE_IDX + 1) { throw new DexIndexOverflowException("Too many type references: " + sz + "; max is " + (DexFormat.MAX_TYPE_IDX + 1) + ".\n" + Main.getTooManyIdsErrorMessage()); } if (out.annotates()) { out.annotate(4, "type_ids_size: " + Hex.u4(sz)); out.annotate(4, "type_ids_off: " + Hex.u4(offset)); } out.writeInt(sz); out.writeInt(offset); }