我正在尝试设置本机反应以在Android模拟器上工作。我正在使用 Ubuntu 18.04。当我尝试使用"反应本机运行-android"时,我收到此错误消息:
BUILD FAILED in 1m 21s
28 actionable tasks: 28 executed
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:
https://facebook.github.io/react-native/docs/getting-started.html
Command failed: ./gradlew installDebug
Error: Command failed: ./gradlew installDebug
at checkExecSyncError (child_process.js:637:11)
at Object.execFileSync (child_process.js:655:13)
at runOnAllDevices (/home/william/react/AwesomeProject/node_modules/react-native/local-cli/runAndroid/runAndroid.js:299:19)
at buildAndRun (/home/william/react/AwesomeProject/node_modules/react-native/local-cli/runAndroid/runAndroid.js:135:12)
at isPackagerRunning.then.result (/home/william/react/AwesomeProject/node_modules/react-native/local-cli/runAndroid/runAndroid.js:65:12)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
此外,它还说:
A problem was found with the configuration of task ‘:app:installDebug’. File ‘/home/william/Android/platform-tools/adb’ specified for property ‘adbExe’ does not exist.
我找到了一个答案,说在我的 set .gradle 中将"/"替换为"在我的反应本机项目中。然而,文件中唯一的问题是:rootProject.name = 'AwesomeProject' 包括 ':app'
我补充了:
export PATH="$HOME/bin:$PATH"
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
到我的巴什克的尽头。
对我来说,解决方案是创建android/local.properties
文件并在磁盘上指定SDK路径 sdk.dir=/username/Android/Sdk