public byte[] convert(String javaFile) throws JadxException { try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream errOut = new ByteArrayOutputStream()) { DxContext context = new DxContext(out, errOut); DxArgs args = new DxArgs(context, "-", new String[]{javaFile}); 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); } return out.toByteArray(); } catch (Exception e) { throw new JadxException("dx exception: " + e.getMessage(), e); } }
/** * Run and exit if something unexpected happened. * @param argArray the command line arguments */ public static void main(String[] argArray) throws IOException { DxContext context = new DxContext(); Arguments arguments = new Arguments(context); arguments.parse(argArray); int result = new Main(context).runDx(arguments); if (result != 0) { throw new IOException(); } }
/** * Run and exit if something unexpected happened. * @param argArray the command line arguments */ public static void main(String[] argArray) throws IOException { DxContext context = new DxContext(); Arguments arguments = new Arguments(context); arguments.parse(argArray); int result = new Main(context).runDx(arguments); if (result != 0) { System.exit(result); } }
/** * Run and return a result code. * @param arguments the data + parameters for the conversion * @return 0 if success > 0 otherwise. */ public static int run(Arguments arguments) throws IOException { return new Main(new DxContext()).runDx(arguments); }
/** * Run and return a result code. * @param arguments the data + parameters for the conversion * @return 0 if success > 0 otherwise. */ public static int run(Arguments arguments) throws IOException { return new Main(new DxContext()).runDx(arguments); }
/** * Run and exit if something unexpected happened. * @param argArray the command line arguments */ public static void main(String[] argArray) throws IOException { DxContext context = new DxContext(); Arguments arguments = new Arguments(); arguments.parseCommandLine(argArray, context); int result = new Main(context).run(arguments); if (result != 0) { System.exit(result); } }
/** * Runs the dex command. * * @return the integer return code of com.android.dx.command.dexer.Main.run() */ public static ProcessResult run( @NonNull DexProcessBuilder processBuilder, @NonNull DexOptions dexOptions, @NonNull ProcessOutputHandler outputHandler) throws IOException, ProcessException { ProcessOutput output = outputHandler.createOutput(); int res; try { DxContext dxContext = new DxContext(output.getStandardOutput(), output.getErrorOutput()); Main.Arguments args = buildArguments(processBuilder, dexOptions, dxContext); res = new Main(dxContext).run(args); } finally { output.close(); } outputHandler.handleOutput(output); return new DexProcessResult(res); }