简体   繁体   中英

Error while executing command 'adb devices' visual studio code

Following the react native documentation, i just created my first react-native app (just npx react-native init AwesomeProject no changes).I also added the enviromentalpath: C:\Users\thijs\AppData\Local\Android\Sdk\platform-tools named ANDROID_HOME under uservariables. But when i try to run my code i get an error

    Stack: Error: Failed to run the application in Android (error code 104): 
    Error while executing command 'adb devices': Command failed: adb devices
    'adb' is not recognized as an internal or external command,
    operable program or batch file.

    at Function.getWrappedError (c:\Users\thijs\.vscode\extensions\msjsdiag.vscode-react-native-1.4.1\dist\rn-extension.js:1:152489)
at Function.wrapError (c:\Users\thijs\.vscode\extensions\msjsdiag.vscode-react-native-1.4.1\dist\rn-extension.js:1:13533)
at c:\Users\thijs\.vscode\extensions\msjsdiag.vscode-react-native-1.4.1\dist\rn-extension.js:1:203519
at processTicksAndRejections (internal/process/task_queues.js:97:5)

When i open cmd and go to the exact location where adb.exe is installed adb device works but when in do it in any other location it won't work

I've tried reinstalling android studio... No results. I've looked at other stackoverflow questions but no one seemed to have the exact same error as mine(i tried they're sollutions but no results).

This is my first time posting here if you need any additional information please ask. Thanks in advance.

You need to add the adb path in Environment Variable path

In your Dir Where Adb is located copy the path

Now add this copied path to the end of PATH of environment variables[System > Advanced System Settings > Environment Variables...

In this Environment Variables window, in the User variables for (your-username) highlight Path and click Edit...] or by

set PATH=%PATH%;your adb folder path

ex - set PATH "%PATH%;C:\Program Files\android-sdk-windows\platform-tools" be careful the path that you want to add if it contains double quote

Try to set your environment variable as per the location of platform-tools

You can find adb in "ADT Bundle/sdk/platform-tools" Set the path and restart the cmd and then try again.

The environment variables gets populated on process start-up, so you just have to restart the terminal (eg command prompt) after you modified the environment variables.

If you are using IDE such as Visual Studio Code, sometimes the terminal session get restored even you restarted. So you might have to kill the terminal too.

If this still not working, just restart your PC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM