【发布时间】:2020-11-04 08:11:29
【问题描述】:
我创建了一个新的 react native 项目并运行了react-native run-android。
但是,我收到此错误:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
这是我的android/build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
我是 react native 的新手,这是一个新项目,因此我们将不胜感激。
【问题讨论】:
-
@Hend El-Sahli 显然没有任何解决方案有帮助,我仍然收到错误。
-
您是否仅在此特定项目中遇到此问题?我的意思是尝试创建一个新项目,看看它是否与您的 RN 安装有关
-
是的,我创建了另一个新的 React Native 项目并遇到了同样的问题。起初它说它缺少
android.jar我手动添加到它的指定文件夹。之后我得到了我在这里发布的这个问题。 -
那么这是一个安装问题...我想通过复制丢失的android.jar文件这不是解决此问题的最佳方法...错误表明您没有安装 Android API ...或部分安装 ...从您的 Android-Studio > Configure > Sdk Manager --> 检查已安装的 api-levels 并确保已安装 API Level-29 .. . 并确保已安装 buildToolsVersion = "29.0.2 或将 buildToolsVersion 设置为您设备中安装的版本
标签: react-native gradle