Windows 下修改了 nodejs 的模块安装位置为 D:\Program Files\nodejs\node_modules\npm_global,运行 java 代码是报错
Error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\adt-bundle\sdk/patform-tools/adb -s 127.0.0.1:62001 push D:\Program Files\nodejs\node_modules\npm_global\node_modules\macaca-android\node_modules\uiautomator-client\bin\uiautoator-bootstrap.jar /data/local/tmp" cannot stat 'D:\Program': No such file or directory
at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:827:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
代码如下
package test;
import com.alibaba.fastjson.JSONObject;
import macaca.client.MacacaClient;
public class Main {
public static void main(String[] args) {
MacacaClient driver = new MacacaClient();
JSONObject porps = new JSONObject();
porps.put("platformName", "android");
porps.put("version", "");
porps.put("javascriptEnabled", true);
porps.put("platform", "ANY");
JSONObject desiredCapabilities = new JSONObject();
desiredCapabilities.put("desiredCapabilities", porps);
try {
driver.initDriver(desiredCapabilities);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}