简体   繁体   English

无法运行程序“adb”:error=2,通过eclipse执行时没有那个文件或目录

[英]Cannot run program "adb": error=2, No such file or directory while executing through eclipse

I am trying to automate android devices using appium in Mac machine(Yosemite OS).我正在尝试在 Mac 机器(Yosemite OS)中使用 appium 自动化 android 设备。

I downloaded and set all the required PATHS like sdk,build-tools,tools,paltform-tools,platforms and able to run the adb commands through terminal sucessfully.我下载并设置了所有必需的路径,如 sdk、build-tools、tools、paltform-tools、platforms,并且能够通过终端成功运行 adb 命令。

But I written sample below java code但是我在java代码下面写了示例

**Process p = Runtime.getRuntime().exec("adb devices");** 

Getting output:获取输出:

Cannot run program "adb": error=2, No such file or directory**无法运行程序“adb”:错误=2,没有那个文件或目录**

I am unable to figure out the exact problem, why it is working through terminal and why i am getting error through eclipse even I set path for everything.我无法弄清楚确切的问题,为什么它通过终端工作,以及为什么即使我为所有内容设置了路径,我也会通过 Eclipse 出错。

Could you please any one suggest me what exactly the issue.Please do the needful.你能请任何人建议我到底是什么问题。请做必要的事情。

could you please try the following line:你能试试下面这行吗:

Process p = Runtime.getRuntime().exec(new String[]{"bash", "-l", "-c", "adb devices"}); Process p = Runtime.getRuntime().exec(new String[]{"bash", "-l", "-c", "adb devices"});

My answer is based on another link in stackoverflow which resolved my problem and it sounds very similar to yours: https://stackoverflow.com/a/54923150/3439297我的回答基于 stackoverflow 中的另一个链接,它解决了我的问题,听起来与您的非常相似: https : //stackoverflow.com/a/54923150/3439297

I faced this issue with IntelliJ community edition+ Mac combo.我在 IntelliJ 社区版 + Mac 组合中遇到了这个问题。 But the reason seems the same, try to invoke your IDE (Eclipse) using the command prompt (Via Terminal) so that it can use the system paths, and in turn recognize adb, you mentioned that adb works from terminal so once the IDE launches from terminal again the paths would be honored.但原因似乎相同,尝试使用命令提示符(通过终端)调用您的 IDE(Eclipse),以便它可以使用系统路径,进而识别 adb,您提到 adb 在终端上工作,因此一旦 IDE 启动再次从终端路径将受到尊重。

You can use following code on Android: To enable the WIFI:您可以在 Android 上使用以下代码: 要启用 WIFI:

String ADB=System.getenv("ANDROID_HOME");
String cmd = "/platform-tools/adb shell am broadcast -a io.appium.settings.wifi --es setstatus enable";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(ADB+cmd);
pr.waitFor();

To Disable the WIFI use:要禁用 WIFI 使用:

String ADB=System.getenv("ANDROID_HOME");
String cmd = "/platform-tools/adb shell am broadcast -a io.appium.settings.wifi --es setstatus disable";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(ADB+cmd);
pr.waitFor();

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

相关问题 Eclipse ADT错误:无法运行程序adb - Eclipse ADT Error: Cannot run program adb 无法运行程序“ osascript”:error = 2,没有这样的文件或目录 - Cannot run program “osascript”: error=2, No such file or directory 无法运行程序“ docker”,错误= 2,无此文件或目录 - Cannot run program “docker” error=2, No such file or directory 无法运行程序“...”错误= 2,没有这样的文件或目录(java) - Cannot run program “…” error=2, No such file or directory (java) 无法运行程序“mvn”错误=2,没有这样的文件或目录 - Cannot run program "mvn" error=2, No such file or directory 无法运行程序“ START”:错误= 2,尝试在MAC中终止Chrome进程时没有此类文件或目录 - Cannot run program “START”: error=2, No such file or directory while trying to kill Chrome process in MAC 詹金斯:无法运行程序“docker”:错误=2,没有那个文件或目录 - Jenkins : Cannot run program “docker”: error=2, No such file or directory 无法运行程序“adb”:错误=13,权限被拒绝 - Cannot run program "adb": error=13, Permission denied 在Eclipse中启动ADB时出错 - Error while starting ADB in Eclipse 无法从IntelliJ插件运行程序“ adb” - Cannot run program “adb” from IntelliJ plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM