Error 3221226356 when running adb command

2020-03-06 07:00发布

问题:

I have started seeing a problem when using the Android ADB. Essentially, on a Windows 10 machine, if I run at the command line:

adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk

Then the application runs and reports 28 (which is correct), but then Windows dialog box is displayed reporting that adb.exe has stopped working.

Running the Appium server and attempting to connect to the emulator also throws an error:

adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk' exited with code 3221226356'; Stderr: ''; Code: '3221226356'

By doing a certain amount of Googling, I think that the two problems are related.

One suggestion made is to re-install an older version of adb, but I can't work out how to do this. Does anyone know?

Alternatively, does anyone know what is causing this problem and how it can be fixed? Here's my environment:

Windows 10 Pro (1809)
Android Studio 3.4.1
Android Debug Bridge version 1.0.41
Version 29.0.0-5611747

I should add that I used to be able to run adb but very recently, I installed an update Android API and in doing so, I was prompted to (I think) update adb and hardware acceleration. Obviously this may be related, but I can't work out how to back out the update.

回答1:

I've encountered the same issue with Appium today after upgrading Android Studio:

[debug] [W3C] Encountered internal error running command: Error: Error getting device platform version. Original error: Error executing adbExec. Original error: 'Command 'C\:\\Users\\Kenny\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s emulator-5554 shell getprop ro.build.version.release' exited with code 3221226356'; Stderr: ''; Code: '3221226356'

As a workaround, downgrading adb (version from 24/04/2015) solved the issue for me. I've downloaded adb from here and replaced the 3 files under my Android SDK folder (mine is: C:\Users\Kenny\AppData\Local\Android\Sdk\platform-tools). After that, adb was working again. I hope this workaround is also working for you.



回答2:

I've just faced this error and made some research. Looks like this error is caused by incompatible adb.exe version (29.0.1-5644136) with Appium (1.13.0). Replacing adb.exe, AdbWinApi.dll, AdbWinUsbApi.dll with previous version solved the problem.


I called in terminal adb version to check what's my adb version.

Android Debug Bridge version 1.0.41
Version 29.0.1-5644136

I replaced it with the previous version and it worked! After replace I had:

Android Debug Bridge version 1.0.41
Version 28.0.3-5475833

I uploaded this version to github in case You could try it Yourself

https://github.com/sephuxeresh/adb_versions/tree/master/1.0.41/28.0.3-5475833