Skip to content

Instantly share code, notes, and snippets.

@Gracker
Created July 4, 2014 03:46
Show Gist options
  • Save Gracker/1416df37cb193921dbf4 to your computer and use it in GitHub Desktop.
Save Gracker/1416df37cb193921dbf4 to your computer and use it in GitHub Desktop.
使用命令行来编译Android .9文件
/**
* 调用aapt工具进行打包
*
* @param resPath
* 资源原路径
* @param outPath
* 打包输出路径
* @return
*/
public static boolean compileNinePatch(String resPath, String outPath) {
// 只编译资源文件
String command = "tools" + File.separator + "aapt-mac";
command += " c";
command += " -S " + resPath;
command += " -C " + outPath;
try {
Runtime.getRuntime().exec(command);
Thread.sleep(3000);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment