简体   繁体   English

使用Runtime.exec()进行适配

[英]aapt using Runtime.exec()

I want to run aapt using the Java runtime. 我想使用Java运行时运行aapt。 My code is as follows: 我的代码如下:

String srcFile = "/home/jay/testing_FILES.apk";
String dsFile = "/home/jay/testing_FILES";
String firstCommand =  ("/home/jay/android-sdk-linux/platform-tools/aapt " +
    "package -u -f -F" + srcFile + dsFile);
try {
  Runtime rt = Runtime.getRuntime();
  Runtime.getRuntime().exec(firstCommand);
} catch (IOException e1) {
  e1.printStackTrace();
}

This code doesn't give me an error, but it doesn't give me any results either. 这段代码没有给我一个错误,但是也没有给我任何结果。 Any thoughts on how to fix this? 有关如何解决此问题的任何想法? Also this is meant to be portable code so if there is a way to do it without scripting that would be preferred. 这也意味着是可移植的代码,因此,如果有一种无需编写脚本就可以做到的方式,那将是首选。

You are trying to put the arguments in the same string as the command; 您正在尝试将参数与命令放在相同的字符串中。 that won't work here because there is no shell to parse them out. 在这里不起作用,因为没有外壳可以解析它们。

You might want to try the form of exec() which takes a string array containing a command and it's arguments. 您可能想尝试exec()的形式,该形式采用包含命令及其参数的字符串数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM