Android examples for App:APK File
build Dex File
//package com.book2s; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { private static final String DX_PATH = "D:\\android_sdk_for_studio\\build-tools\\22.0.1\\dx.bat"; private static final String batchDir = System.getProperty("user.dir") + "\\batch\\"; private static void buildDexFile(String projectDir) { StringBuffer command = new StringBuffer(); command.append(DX_PATH).append(" --dex --output=") .append(projectDir).append("\\bin\\classes.dex") .append(" ").append(projectDir).append("\\bin"); buildExeBatchFiles(command.toString(), "3.bat"); }//from w w w .j a v a 2 s . c o m private static void buildExeBatchFiles(String command, String fileName) { System.out.println(command); if (!new File(batchDir).exists()) { new File(batchDir).mkdirs(); } String filePath = batchDir + fileName; try { writeFile(filePath, command); } catch (IOException e) { e.printStackTrace(); } } private static void writeFile(String filePath, String content) throws IOException { FileWriter fw = new FileWriter(filePath); PrintWriter out = new PrintWriter(fw); out.write(content); out.println(); fw.close(); out.close(); } }