首页 > 解决方案 > 已弃用的 Gradle 功能不兼容

问题描述

运行时出现此错误react-native run-android

日志:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Android Gradle Plugin Version - 3.6.3
Gradle Version- 6.0.1

标签: react-nativeandroid-studioreact-native-androidandroid-sdk-manager

解决方案


  • 更新以下文件:

gradle-wrapper.properties

 distributionUrl=https://services.gradle.org/distributions/gradle-6.0.1-all.zip

android/app/build.gradle

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true   //add this
}
  • 更新所有第三方依赖项
  • 如果错误仍然存​​在,请运行以下命令:

    cd android && ./gradlew clean && ./gradlew :app:bundleRelease
    
  • 如果它仍然存在,试试这个:

    npm install --save-dev jetifier
    npx jetify
    npx react-native run-android
    

推荐阅读