Skip to content

Instantly share code, notes, and snippets.

@Gracker
Created July 4, 2014 02:39
Show Gist options
  • Save Gracker/1236f18e3b85914b92e7 to your computer and use it in GitHub Desktop.
Save Gracker/1236f18e3b85914b92e7 to your computer and use it in GitHub Desktop.
public static void compileNinePatch() {
File projectRootPath = new File("ThemeTools");
File manifest = new File("lewaThemeTools" + File.separator
+ "AndroidManifest.xml");
File android = new File("lewaThemeTools" + File.separator + "libs"
+ File.separator + "android.jar");
File resource = new File("temp" + File.separator + "drawable");
File tempFile = new File("temp" + File.separator + "temp.zip");
File tempFolder = new File("temp" + File.separator + "temp");
command = "res" + File.separator + "aapt-mac";
command += " package";
command += " -M " + manifest.getAbsolutePath();
command += " -S " + resource.getAbsolutePath();
command += " -I " + android.getAbsolutePath();
command += " -F " + tempFile.getAbsolutePath();
System.out.println(command);
try {
Runtime.getRuntime().exec(command);
Thread.sleep(3000);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
if (tempFile.exists()) {
unZip("temp" + File.separator + "temp.zip",
tempFolder.getAbsolutePath());
} else {
System.out.println("打包不成功");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment