我使用react-native init ...
创建了一个新应用程序。按照文档安装了 android 开发工具并尝试使用 react-native run-android
运行。
我收到错误
FAILURE: Build failed with an exception.
What went wrong: A problem was found with the configuration of task ':app:installDebug'. File 'C:\Android\sdk\platform-tools\adb.exe' specified for property 'adbExe' does not exist.
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: 1 mins 7.058 secs
我已经尝试过几次(删除然后重新安装 SDK 等),我注意到当我安装 SDK 和工具时,adb
安装在上述位置,但是当构建启动/模拟器启动或 android studio 加载项目时,它就会消失(删除?)。
无论我是否运行 react-native run-android
或在 Android Studio (3.0.1) 中打开 [AppFolder]\android
并运行 [Run > 运行“应用程序”]
我将platform-tools文件夹复制到其他地方,并在android studio打开后替换它,并且当android studio或模拟器运行时adb仍然在几秒钟后消失。如果我运行 react-native run android
也是如此。
同一项目在 OS X 上运行良好。(克隆项目后我必须手动 chmod +x gradlew
但我不认为这是相关的。)
配置
- 操作系统 Windows 10 v1709(内部版本 16299.125)- 无待更新
- react 原生0.51
- 安卓工作室3.0.1
- gradle 版本我认为如下所示为 2.2.3
build.gradle 文件 (我没有改变这个 - 由react-native cli生成)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
SDK 安装后立即
运行 android studio 并打开项目/启动模拟器/react-native run-android
最佳答案
您可以尝试将 adb.exe 放在其他位置,并确保它位于路径中吗? 会不会是某些防病毒软件删除了它?
关于android-studio - 构建 Android 应用程序会删除 adb 可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47965509/