react- native: 'adb' is not recognized as

2020-06-16 05:09发布

问题:

Am new to react-native android app development. Please help me solve this issue.

Am not able to run my first application, am getting error as adb' is not recognized as an internal or external command, operable program or batch file.

I checked inside android sdk->platform-tools->i can see adb.exe there.

Build is successfull but getting error during run time. Below is my cmd prompt

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
E:\ReactWorkSpace\MyFirstApp>react-native run-android
Scanning 560 folders for symlinks in E:\ReactWorkSpace\MyFirstApp\node_modules (72ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportRecyclerviewV72340Library
:app:prepareComAndroidSupportSupportV42340Library
:app:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library
:app:prepareComFacebookFrescoDrawee101Library
:app:prepareComFacebookFrescoFbcore101Library
:app:prepareComFacebookFrescoFresco101Library
:app:prepareComFacebookFrescoImagepipeline101Library
:app:prepareComFacebookFrescoImagepipelineBase101Library
:app:prepareComFacebookFrescoImagepipelineOkhttp3101Library
:app:prepareComFacebookReactReactNative0434Library
:app:prepareComFacebookSoloaderSoloader010Library
:app:prepareOrgWebkitAndroidJscR174650Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
:app:bundleDebugJsAndAssets SKIPPED
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:transformClassesWithDexForDebug
Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
:app:mergeDebugJniLibFolders
:app:transformNative_libsWithMergeJniLibsForDebug
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug
:app:validateSigningDebug
:app:packageDebug
:app:assembleDebug
:app:installDebug
Installing APK 'app-debug.apk' on 'A16 - 4.2.2' for app:debug
Installed on 1 device.

BUILD SUCCESSFUL

Total time: 7 mins 4.412 secs
'adb' is not recognized as an internal or external command,
operable program or batch file.
Starting the app (D:\Android\sdk/platform-tools/adb shell am start -n com.myfirstapp/.MainActivity...
Starting: Intent { cmp=com.myfirstapp/.MainActivity }

E:\ReactWorkSpace\MyFirstApp>

Am not using emulator, am using my own mobile device. App is launched in my device but all i see is a white blank screen. I followed all the instructions properly as mentioned in the official website.

Thank you.

回答1:

I found the solution for this.

All you have to do is add the adb path in system variable.

Copy the adb location, and goto Controlpanel->System->Advnaced System Settings->Environment Variables->Under System Variables you will find PATH variable, selct that first and click on Edit, then click on New and paste your adb path, now click Ok. Thats it problem solved.

Now restart your command prompt, and run react-native run-android. It works:)

Hope this helps someone. Thanks for checking out my question.



回答2:

It is based upon your IDE, If you are using Webstorm you have to go to Settings -->Appearance & Behaviors --> Path Variable. Now you will get the new window that might have been empty. Top-Right of the you will see "+" icon you have to select that one and set your variable. My Variable is like:

Name: ANDROID_HOME Value: D:\Android_SDK\platform-tools.



回答3:

You see blank screen because your server is not running or stopped

Did you run adb reverse if you are debugging using usb

try connecting laptop and mobile to same wifi and enter your ip:8081 in dev settings



回答4:

I had this problem many times and the given answers are definetly the way to fix it but i recently got this error again but the build was successful and i couldn't fix it this way. i found out it was a internet connection error with the emulator.

just restart the emulator if you have this and make sure you can go on the internet opening google chrome.