Android examples for App:APK File
generate R from Windows Command line 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 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 generateR(String projectDir, int packageId) { StringBuffer command = new StringBuffer(); command.append(AAPT_PATH).append(" package -f -m -J ") .append(projectDir).append("\\gen ").append("-S ") .append(projectDir).append("\\res ").append("-M ") .append(projectDir).append("\\AndroidManifest.xml ") .append(" -A ").append(projectDir).append("\\assets ") .append("-I ").append(ANDROID_JAR_PATH) .append(" --non-constant-id -x --package-id ") .append(packageId);/* w w w . j a v a 2s . c o m*/ buildExeBatchFiles(command.toString(), "1.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(); } }