Appium no longer working with an AVD after latest Android Studio update

I’ve been using Appium on a virtual Android device (started from Android Studio) without issue for a while now. Yesterday morning I updated Android Studio, and since then I haven’t been able to use Appium anymore. The inspector which I try to run gives the following error message:
An unknown server-side error occurred while processing the command. Original error: Error getting device API level. Original error: Error executing adbExec. Original error: ‘Command ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’ exited with code 3221226356’; Stderr: ‘’; Code: ‘3221226356’

Interestingly, when I run that command manually in a command prompt, it works without issue.

This has been occuring on a Windows 10 machine, running Android Studio 3.4.1 and using Android SDK 29.0.0, and running Appium 1.13. My AVD runs Android 8.1 (API level 27).
I have tried to reinstall both Appium and Android Studio (also deleting the Android SDK folder, so that was reinstalled as well), and I have downgraded my Android SDK to 28.0.0 and later 27.0.0, all without success. I have also created a new AVD (same Android version), but no luck there either.

The capabilities I use for the Appium inspector are as follows:
{
“platformName”: “Android”,
“deviceName”: “Pixel 2”,
“app”: “/Users/stefane/Downloads/app-qa-930-169.apk”,
“automationName”: “uiautomator2”
}

The logs show the following:
[MJSONWP] Calling AppiumDriver.createSession() with args: [{“app”:"/Users/stefane/Downloads/app-qa-930-169.apk",“automationName”:“uiautomator2”,“deviceName”:“Pixel 2”,“platformName”:“Android”,“newCommandTimeout”:0,“connectHardwareKeyboard”:true},null,null]
[BaseDriver] Event ‘newSessionRequested’ logged at 1559891899074 (09:18:19 GMT+0200 (West-Europa (zomertijd)))
[Appium] Appium v1.13.0 creating new AndroidUiautomator2Driver (v1.33.1) session
[Appium] Capabilities:
[Appium] app: /Users/stefane/Downloads/app-qa-930-169.apk
[Appium] automationName: uiautomator2
[Appium] deviceName: Pixel 2
[Appium] platformName: Android
[Appium] newCommandTimeout: 0
[Appium] connectHardwareKeyboard: true
[BaseDriver] Creating session with MJSONWP desired capabilities: {“app”:"/Users/stefane/Down…
[BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
[BaseDriver] Session created with session id: 76d2ca20-6c7a-44bc-a16f-80313b0f8400
[BaseDriver] Using local app ‘/Users/stefane/Downloads/app-qa-930-169.apk’
[UiAutomator2] Checking whether app is actually present
[ADB] Found 1 ‘build-tools’ folders under ‘C:\Users\stefane\AppData\Local\Android\Sdk’ (newest first):
[ADB] C:/Users/stefane/AppData/Local/Android/Sdk/build-tools/29.0.0
[ADB] Using ‘adb.exe’ from ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe’
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[AndroidDriver] Using device: emulator-5554
[ADB] Using ‘adb.exe’ from ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe’
[ADB] Setting device id to emulator-5554
[ADB] Running ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’
[UiAutomator2] Deleting UiAutomator2 session
[ADB] Removing forwarded port socket connection: 8200
[ADB] Running ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:8200’
[UiAutomator2] Unable to remove port forward ‘Error executing adbExec. Original error: ‘Command ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 forward --remove tcp:8200’ exited with code 1’; Stderr: ‘adb.exe: error: listener ‘tcp:8200’ not found’; Code: ‘1’’
[ADB] Running ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’
[BaseDriver] Event ‘newSessionStarted’ logged at 1559891919493 (09:18:39 GMT+0200 (West-Europa (zomertijd)))
[MJSONWP] Encountered internal error running command: Error: Error getting device API level. Original error: Error executing adbExec. Original error: ‘Command ‘C:\Users\stefane\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’ exited with code 3221226356’; Stderr: ‘’; Code: ‘3221226356’
[MJSONWP] at ADB. (C:\Users\stefane\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\adb-commands.js:98:13)
[MJSONWP] at Generator.throw ()
[MJSONWP] at asyncGeneratorStep (C:\Users\stefane\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules@babel\runtime\helpers\asyncToGenerator.js:3:24)
[MJSONWP] at _throw (C:\Users\stefane\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules@babel\runtime\helpers\asyncToGenerator.js:29:9)
[MJSONWP] at run (C:\Users\stefane\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\core-js\modules\es6.promise.js:75:22)
[MJSONWP] at C:\Users\stefane\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\core-js\modules\es6.promise.js:92:30
[MJSONWP] at flush (C:\Users\stefane\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\core-js\modules_microtask.js:18:9)
[MJSONWP] at process._tickCallback (internal/process/next_tick.js:61:11)

Would anyone here know what the issue is, or where I can look into this further?

Cheers,
Stefan

It looks like I was able to solve my problem. I followed the instruction from this link:
http://www.sofment.com/?q=node/14

Using that, I downgraded platform tools to 28.0.1 (originally 29), and no I have no issues so far.
So looking at the Android Studio SDK manager, I use:
So right now I’m using:
Android SDK Build Tools 29
Android SDK Platform Tools 28.0.1

I have run a few tests, and apart from some weird behaviour I haven’t seen before I’ve had no issues.

Somewhat similar situation after updating Android Studio on Ubuntu Linux 16.04. Programmatical start of all chain of Appium/ADB/emulator/etc. worked ok before update but now it doesn’t see build-tools although it is present (even two of them - 29.0.0, 28.0.3).

[ADB] Found 0 ‘build-tools’ folders under '/home/kuzmych/Android/Sdk ’ (newest first):
[HTTP] <-- POST /wd/hub/session 500 177 ms - 1047
[HTTP]

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Could not find ‘adb’ in ["/home/kuzmych/Android/Sdk /platform-tools/adb","/home/kuzmych/Android/Sdk /emulator/adb","/home/kuzmych/Android/Sdk /tools/adb","/home/kuzmych/Android/Sdk /tools/bin/adb"]. Do you have Android Build Tools installed at '/home/kuzmych/Android/Sdk '?
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’
System info: host: ‘Kuzmych-PC’, ip: ‘127.0.1.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘4.15.0-51-generic’, java.version: ‘1.8.0_212’
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not find ‘adb’ in ["/home/kuzmych/Android/Sdk /platform-tools/adb","/home/kuzmych/Android/Sdk /emulator/adb","/home/kuzmych/Android/Sdk /tools/adb","/home/kuzmych/Android/Sdk /tools/bin/adb"]. Do you have Android Build Tools installed at '/home/kuzmych/Android/Sdk '?
at getResponseForW3CError (/usr/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
at asyncHandler (/usr/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:447:37)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’

All access permissions are fine. I already tried to reinstall Android studio and all sdk, recreated emulators but it doesn’t help.

And strangely Appium Desktop is able to start emulator and install application.

Like the previous author I resolved this issue by myself. I completely deleted and reinstalled all mobile automation environment from scratch (includinп Node, Appium Server, Appium Desktop, Android studio + sdk), rewrote all environmental settings (ANDROID_HOME etc) and cloned automation project. Still have an impression 29.0.0 might bring troubles when comes as update, because it is the only thing that changed in between working and defunct autotests.

i did same nothing happened,

i replaced adb.exe file with older version adb and its work perfect.
just replace adb.exe not platform_tools folder.

My build tools are under C:\Users\stefane\AppData\Local\Android\Sdk\build-tools
Is one of you build tool folders named “build-tools”, and not “build-tools-29” or similar? The only reasons I could think of why your build tool folders are not detected is either the naming, or the folders might be missing one or more files.

Which versions of which software do you use? I’m no expert at this by any means, but I might be able to help out.

download platform tools version 26 and then copy adb from that downloaded folder and replace it with your current adb in platform tools.
https://developer.android.com/studio/releases/platform-tools

Its an ADB bug, thats throws this error however any command throw cmd will be executed normally without any issue,

Issue will be solved buy downgraded the adb version with previous version 28.0.3 it will work fine
Delete entire folder of platform-tools and replace it it with paltform-tools related to previous version

I checked consistency both naming-wise and file-wise. It was all ok. Build tools rested in build-tools/28.0.3 and 29.0.0. And I gave all the Unix permissions to folders and files. It didn’t help. Only full re-setup of testing stack helped. Unfortunately I have no idea what happened just the fact 29.0.0 update came automatically to Android studio and after all that trouble started. Anyway thank you very much!