java 找不到亚行。请使用Android SDK根目录路径设置ANDROID_HOME环境变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32293499/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 19:58:39  来源:igfitidea点击:

Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path

javac#androidappium

提问by MoHaMmAd

I Create a Sample for lunch whatsapp with appium and C# .NET

我使用 appium 和 C# .NET 创建了一个午餐 whatsapp 示例

static void Main(string[] args)
        {
            Console.WriteLine("Hi");
            AndroidDriver<AndroidElement> driver;
            DesiredCapabilities capabilites = new DesiredCapabilities();
            capabilites.SetCapability("deviceName", "Google Nexus 5 - 5.0.0 - API 21 - 1080x1920");
            capabilites.SetCapability("platformversion", "5.1.0");
            capabilites.SetCapability("platformname", "Android");
            capabilites.SetCapability("appPackage", "com.whatsapp");
            capabilites.SetCapability("appActivity", "com.whatsapp.Main");
            driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilites);
            //com.whatsapp:id/registration_phone
            driver.FindElement(By.Id("com.whatsapp:id/registration_phone"));
            Thread.Sleep(10000);
            driver.Quit();
        }

I start appium, I can get my device and I can see my device in ui automator viewer .

我启动 appium,我可以得到我的设备,我可以在 ui automator viewer 中看到我的设备。

http://i.cubeupload.com/vWTznm.png

http://i.cubeupload.com/vWTznm.png

But when I Run My Program I get this Error on this Line :

但是当我运行我的程序时,我在这条线上收到这个错误:

http://i.cubeupload.com/ENGYvU.png

http://i.cubeupload.com/ENGYvU.png

and I set PATH and ANDROID_PATH : ANDROID_PATH : C:\Users\user\AppData\Local\Android\sdk PATH : %PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools all of them are correct and true

我设置了 PATH 和 ANDROID_PATH : ANDROID_PATH : C:\Users\user\AppData\Local\Android\sdk PATH : %PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools 所有这些都是正确和真实的

I guess this problem becuse i have more than one SDK 1. for android studio : C:\Users\user\AppData\Local\Android\sdk 2. for eclipse : C:\android\sdk\android

我猜这个问题是因为我有多个 SDK 1. 对于 android studio :C:\Users\user\AppData\Local\Android\sdk 2. 对于 eclipse :C:\android\sdk\android

How I can chose a specific SDK location for my C# program .

如何为我的 C# 程序选择特定的 SDK 位置。

回答by vishal

you can also go into Eclipse --> Run Menu--> Run Confiuguration -->Environment Tab--> ANDROID_HOME --> Give Path to the SDK folder

您也可以进入 Eclipse --> 运行菜单--> 运行配置 --> 环境选项卡--> ANDROID_HOME --> 提供 SDK 文件夹的路径

Also as other suggested set your path variable. Taken from https://www.java.com/en/download/help/path.xml

也作为其他建议设置您的路径变量。来自https://www.java.com/en/download/help/path.xml

Windows Windows 10 and Windows 8

In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

Windows 7

From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

Windows Vista

From the desktop, right click the My Computer icon.
Choose Properties from the context menu.
Click the Advanced tab (Advanced system settings link in Vista).
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

Windows XP

Select Start, select Control Panel. double click System, and select the Advanced tab.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

视窗 视窗 10 和视窗 8

In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

环境变量不存在,点击新建。在 Edit System Variable(或 New System Variable)窗口中,指定 PATH 环境变量的值。单击确定。单击确定关闭所有剩余的窗口。重新打开命令提示符窗口,并运行您的 Java 代码。

Windows 7的

From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

环境变量不存在,点击新建。在 Edit System Variable(或 New System Variable)窗口中,指定 PATH 环境变量的值。单击确定。单击确定关闭所有剩余的窗口。重新打开命令提示符窗口,并运行您的 Java 代码。

视窗 Vista

From the desktop, right click the My Computer icon.
Choose Properties from the context menu.
Click the Advanced tab (Advanced system settings link in Vista).
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

环境变量不存在,点击新建。在 Edit System Variable(或 New System Variable)窗口中,指定 PATH 环境变量的值。单击确定。单击确定关闭所有剩余的窗口。重新打开命令提示符窗口,并运行您的 Java 代码。

视窗 XP

Select Start, select Control Panel. double click System, and select the Advanced tab.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

环境变量不存在,点击新建。在 Edit System Variable(或 New System Variable)窗口中,指定 PATH 环境变量的值。单击确定。单击确定关闭所有剩余的窗口。重新打开命令提示符窗口,并运行您的 Java 代码。

回答by crujzo

SET Environment variables in Eclipse(IDE) locally with ANDROID_HOME and then try to run...it worked fine for me

使用 ANDROID_HOME 在 Eclipse(IDE) 本地设置环境变量,然后尝试运行...它对我来说很好用

回答by Oleksandr Loushkin

You can write BAT file for starting appium process. Inside of this batch file write SET ANDROID_HOME = blabla, it will override system variable.

您可以编写 BAT 文件来启动 appium 进程。在此批处理文件中写入 SET ANDROID_HOME = blabla,它将覆盖系统变量。

回答by Tabish Javed

Check if system32 is present as path variable

检查 system32 是否作为路径变量存在