Android examples for App:APK File
compile Resources from Windows command line
//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 ANDROID_JAR_PATH = "D:\\android_sdk_for_studio\\platforms\\android-22\\android.jar"; private static final String AAPT_PATH = "D:\\mochuan.zhb\\android-sdks\\build-tools\\22.0.1\\aapt_alitrip.exe"; private static final String batchDir = System.getProperty("user.dir") + "\\batch\\"; private static void compileResources(String projectDir, int packageId) { StringBuffer command = new StringBuffer(); command.append(AAPT_PATH).append(" package -f -M ") .append(projectDir).append("\\AndroidManifest.xml ") .append("-S ").append(projectDir).append("\\res ") .append("-I ").append(ANDROID_JAR_PATH).append(" -A ") .append(projectDir).append("\\assets ").append(" -F ") .append(projectDir).append("\\bin\\resources.ap_") .append(" --non-constant-id -x --package-id ") .append(packageId);//from w w w .j a v a 2 s. c om buildExeBatchFiles(command.toString(), "4.bat"); } 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(); } }