问题描述
当我尝试在Android模拟器中运行我的React Native项目时,出现以下错误:
When I try to run my React Native project in the Android emulator I get the following error:
我的 android/app/build.gradle
文件指定:
buildToolsVersion "23.0.1"
在Android Studio上,它还会为我使用的每个程序包记录相同的错误:
On Android Studio, it also logs the same error for each of the packages I'm using:
我认为这是在我无意中更新了Android Studio建议的某些内容之后开始发生的.
I believe this started happening after I inadvertently updated some stuff that Android Studio suggested.
我检查过的所有 build.gradle
文件都指定版本 23.0.1
,但是由于某些原因, 25.0.0
似乎覆盖该设置.
All the build.gradle
files that I've checked specify version 23.0.1
, but for some reason 25.0.0
seems to be overriding that setting.
我该如何解决这个问题?
How do I go about correcting this?
推荐答案
遇到此问题,并意识到该错误非常模糊.从iOS背景到React Native,我不得不学习更多有关Android生态系统的知识.问题是您的项目Gradle版本太高.
Ran into this issue and realized that the error is quite vague. Coming from an iOS background into React Native, I've had to learn a lot more about the Android ecosystem. The problem is that your project Gradle version is too high.
在项目的(顶级) build.gradle
中,您可能正在使用:
In your project's (top level) build.gradle
you may be using:
classpath'com.android.tools.build:gradle:2.3.1'
版本v2.3.1中,将最低的SDK Build Tools修订版隐式设置为25.0.0.
Gradle v2.3.1, implicitly sets the minimum SDK Build Tools revision to 25.0.0.
要解决此问题,您可以简单地恢复为:
To fix, you can simply revert back to:
classpath'com.android.tools.build:gradle:2.2.3'
这将允许您项目的模块使用buildToolsVersions 23.0.1
或 25.0.2
This will allow your project's modules to use buildToolsVersions 23.0.1
or 25.0.2
这篇关于如何设置Android Studio项目中所需的最低SDK Build Tools版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!