【问题标题】:React native Android emulator error on Ubuntu 18.04在 Ubuntu 18.04 上反应原生 Android 模拟器错误
【发布时间】:2019-02-05 17:29:53
【问题描述】:

我正在尝试设置 react native 以在 android 模拟器上工作。我正在使用 Ubuntu 18.04。当我尝试使用“react-native run-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.

我在我的 react native 项目中的 settings.gradle 中找到了一个答案,上面写着将“/”替换为“”。文件中唯一的内容是:rootProject.name = ‘AwesomeProject’ include ‘: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

到我的 bashrc 结尾。

【问题讨论】:

  • 你是在添加PATH之后运行source ~/.bashrc,还是尝试打开一个新的终端运行react? React 找不到 adb 二进制文件,因此要么未设置 PATH,要么未安装 adb。您能否验证adb 是否安装在Android/Sdk/platform-tools/adb 上?
  • 我已经更新了 bashrc 是的。有一个文件,但没有一个名为 adb 的文件夹是的

标签: android android-studio react-native gradle


【解决方案1】:

我的解决方案是创建 android/local.properties 文件并在您的磁盘上指定 SDK 路径 sdk.dir=/username/Android/Sdk

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-08
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多