Android - Encountered internal error running command: Error: ENOENT: no such file or directory, scandir

Appium Version: 1.5.2 (Ara)
Android Studio Version: 2.1
Eclipse Version: 4.5.2

Summary:
I’m getting the error Encountered internal error running command: Error: ENOENT: dos such file or directory, scandir ‘/User/[UserName]/Library/Android/sdk/build-tools’

I’m attempting to execute a Android test from a XML document within my Eclipse solution when I get the above error.
This same test ran successfully when I executed it directly from Eclipse.

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“avd”, strAVDName.replace(" “,”_"));
capabilities.setCapability(“deviceName”,strAVDName);
capabilities.setCapability(“unicodeKeyboard”, “true”);
String apkpath=strUserDir+"/APK/BlahBlahBlah.apk";
File app=new File(apkpath);capabilities.setCapability(“app”, app.getAbsolutePath());
return new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Logs
[BaseDriver] Capability ‘unicodeKeyboard’ changed from string to boolean. This may cause unexpected behavior
[BaseDriver] Session created with session id: 926e6343-3510-4552-b7c1-5c1f92c1cbf4
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.7.0_79
[ADB] Checking whether adb is present
[debug] [AndroidDriver] Shutting down Android driver
[AndroidDriver] Cannot shut down Android driver; it has already shut down
[MJSONWP] Encountered internal error running command: Error: ENOENT: no such file or directory, scandir ‘/User/darinduphorn/Library/Android/sdk/build-tools’
at Error (native)
[HTTP] <-- POST /wd/hub/session 500 105 ms - 232

It appears that it’s looking for build-tools in the wrong directory.

I’m guessing it should be looking in /Users instead of /User

[MJSONWP] Encountered internal error running command: Error: ENOENT: no such file or directory, scandir ‘/User/[UserName]/Library/Android/sdk/build-tools’
at Error (native)

Thoughts?

Ah, I figured it out.

In my Eclipse -> Run Configurations… under my Under Environments tab I had /User instead of Users.

My bad :slight_smile: Closed

In this case, you might also want to check how you’re setting up your ANDROID_HOME environment variable. It might reference the wrong directory as well.

Hi,

I’m facing the same issue which is raised above. I can’t get the solution for this issue.

Here is my bashrc
export PATH=$PATH:/Users/admin/Library/Android/sdk/platform-tools
export PATH=$PATH:/Users/admin/Library/Android/sdk/tools
export PATH=$PATH:/Users/admin/Library/Android/sdk/build-tools
export ANDROID_HOME=$ANDROID_HOME:/Users/admin/Library/Android/sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
export PATH=$PATH:/usr/local/share/npm/bin/
export PATH=$PATH:/Users/admin/Library/Android/sdk/platform-tools/adb.exe
[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm” # Load RVM into a shell session as a function
source ~/.profile

Below is the error log…

[MJSONWP] Calling AppiumDriver.createSession() with args: [{“app”:"/Users/admin…
[Appium] Creating new AndroidUiautomator2Driver session
[Appium] Capabilities:
[Appium] app: ‘/Users/admin/Desktop/test-qa-0.1.13.apk’
[Appium] newCommandTimeout: ‘600’
[Appium] platformVersion: ‘6.0’
[Appium] automationName: ‘uiautomator2’
[Appium] platformName: ‘Android’
[Appium] deviceName: ‘TestDevice’
[BaseDriver] Capability ‘newCommandTimeout’ changed from string (‘600’) to integer (600). This may cause unexpected behavior
[BaseDriver] Session created with session id: 9742038b-2b69-486b-8483-da7abc50b88c
[BaseDriver] Using local app ‘/Users/admin/Desktop/test-qa-0.1.13.apk’
[debug] [UiAutomator2] Checking whether app is actually present
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_45
[ADB] Checking whether adb is present
[debug] [UiAutomator2] Deleting UiAutomator2 session
[MJSONWP] Encountered internal error running command: Error: ENOENT: no such file or directory, scandir ‘/Users/admin/IdeaProjects/TestSerenityAppiumAutomationUI/:/Users/admin/Library/Android/sdk/build-tools’
at Error (native)

Could anyone help me with this issue will be a great favour please?

Many Thanks in Advance

Hi,

Did you resolve the issue, even I’m facing similar problem

Thanks & Regards,
Vikram

In my case, the environment variable was,
ANDROID_HOME=:\Users…\AppData\Local\Android\Sdk
Obviously c: missing. Appium could not locate build-tools directory.

I changed ANDROID_HOME to c:\Users…\AppData\Local\Android\Sdk
It worked fine.

I can not believe, I configured it wrong.
Did some software install mess it up?

May be I did it.

Hello, I have a similar problem when running my test in JAVA on MAC.
As for my log, it looks like follow:

[Appium] Creating new AndroidDriver (v1.17.1) session
[Appium] Capabilities:
[Appium] app: ‘/Users/david/Eclipse-workspace/UdemyTesting/src/ApiDemos-debug.apk’
[Appium] platformName: ‘Android’
[Appium] deviceName: ‘Nexus5’
[AndroidDriver] AndroidDriver version: 1.17.1
[BaseDriver] Session created with session id: 6b42d544-8068-40b2-8cb4-429d37458e6d
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_131
[ADB] Checking whether adb is present
[AndroidDriver] Shutting down Android driver
[AndroidDriver] Called deleteSession but bootstrap wasn’t active
[MJSONWP] Encountered internal error running command: Error: ENOENT: no such file or directory, scandir ‘/Users/username/Library/Android/sdk/build-tools’
at Error (native)
[HTTP] <-- POST /wd/hub/session 500 123 ms - 229

I have

  • appium version 1.6.4
  • java client 4.1.2
  • avd -> Nexus_5_API_23
  • selenium-java 3.4.0

Please help!
Cheers!

Still dont know what the problem is but I could run it starting Appium from command line instead of desktop app.
Cheers

notice:

no such file or directory, scandir ‘/Users/username/Library/
Android/sdk/build-tools’

This may be because environmental variables messed up as happened to me.

I think PATH has problem. Check in the path one of the settings does not
include c: or drive name relevant.

For me ANDROID_HOME was the culprit.

If you have a problem, send me PATH. I will have a look.

Hi,

I am facing similar issue
I am using Android studio, robot framework, pycharm and Appium server app
This setup was working fine, but now I when I run a test, I am getting error as follows
Windows 10 PC

Error: ENOENT: no such file or directory, scandir ‘C:\Users\Hp-pc\AppData\Local\Android\sdk\platform-tools\build-tools’

Any suggestions…
I have set path variable in advanced system settings