我尝试运行我的react-native项目但是我得到了这个错误:
Aniss-Cherkaoui:AwesomeProject Error_404 $ react-native run-android 启动JS服务器...... / bin / sh:adb:找不到命令 在设备上构建和安装应用程序(cd android&& ./gradlew installDebug ... :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :应用:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42321Library UP-TO-DATE :app:prepareComFacebookFrescoDrawee0110Library UP-TO-DATE :app:prepareComFacebookFrescoFbcore0110Library UP-TO-DATE :app:prepareComFacebookFrescoFresco0110Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipeline0110Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipelineBase0110Library UP-TO-DATE :app:prepareComFacebookFrescoImagepipelineOkhttp30110Library UP-TO-DATE :app:prepareComFacebookReactReactNative0370Library UP-TO-DATE :app:prepareComFacebookSoloaderSoloader010Library UP-TO-DATE :app:prepareOrgWebkitAndroidJscR174650Library UP-TO-DATE :应用:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:bundleDebugJsAndAssets SKIPPED :app:processDebugManifest UP-TO-DATE :app:processDebugResources FAILED
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > at index 4 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 10.769 secs Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment. Go to https://facebook.github.io/react-native/docs/getting-started.html and check the Android tab for setup instructions.
答案 0 :(得分:9)
请确保您已经安装了sdk并正确设置了sdk和android platform-tools的路径。
检查你的.bashrc文件,或者如果在mac上检查.bashprofile。
每次运行应用程序时,您都可以这样做。在项目文件夹中运行以下命令。(如果您遵循官方RN文档,这些路径将起作用。)
导出ANDROID_HOME =〜/ Library / Android / sdk
export PATH = $ {PATH}:$ {ANDROID_HOME} / tools
export PATH = $ {PATH}:$ {ANDROID_HOME} / platform-tools
答案 1 :(得分:1)
安装过程中可能出现问题,因为你缺少abd。 尝试重新安装或者首先运行更新:
cd ~/Library/Android/sdk/tools/
./android update sdk -u
在我的Mac中,abd指向这里:
ls -an /usr/local/bin/
adb@ -> ../Cellar/android-platform-tools/24/bin/adb
确保至少安装了一个SDK。 (在Android工作室中使用SDK管理器)。
答案 2 :(得分:0)
./ android update sdk -u
已被弃用。使用
./ bin / sdkmanager --update
相反,如果你想通过命令行来完成它。