You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React开发者尝试React Native时遇Gradle兼容错误,求助解决方案

Fixing "Deprecated gradle features were used in this build" in React Native

Hey there! I totally get how frustrating it is to hit a Gradle roadblock when you're just dipping your toes into React Native—especially coming from a React web background where build tools work a bit differently. Let's walk through how to squash this error step by step:

  • First, check your Gradle wrapper version
    Head over to android/gradle/wrapper/gradle-wrapper.properties and look at the distributionUrl line. It should look something like:

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

    If your version is older than 6.0, you'll need to upgrade it—but make sure to pick a version compatible with your React Native release (for example, RN 0.70+ works well with Gradle 7.x).

  • Update the Android Gradle Plugin
    Open android/build.gradle and find the classpath entry for the Android Gradle Plugin. This version needs to match your Gradle version (roughly: Gradle 6.x uses plugin 4.x, Gradle 7.x uses plugin 7.x). For example:

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        // other dependencies...
    }
    
  • Replace deprecated dependency keywords
    Old Gradle syntax like compile, testCompile, and androidTestCompile are deprecated. Go into android/app/build.gradle and swap them out with:

    • implementation (instead of compile)
    • testImplementation (instead of testCompile)
    • androidTestImplementation (instead of androidTestCompile)
  • Clean and rebuild your project
    Sometimes cached build files cause lingering issues. Run these commands in your terminal:

    cd android
    ./gradlew clean
    cd ..
    npx react-native run-android
    
  • Get specific details about the deprecated features
    If you still aren't sure exactly what's triggering the error, run this command to see a full breakdown of deprecated usage:

    cd android
    ./gradlew build --warning-mode all
    

    This will list every deprecated feature in your build scripts, so you can fix them one by one.

Since you're new to React Native, remember the framework has tight version compatibility between itself, Gradle, and the Android Gradle Plugin—sticking to the versions recommended for your RN release will save you a lot of headaches.

内容的提问来源于stack exchange,提问作者sherin shaju

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:37:38