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

React Native项目构建报错:无法找到com.android.tools.build:gradle:3.0.1

Fixing "Could not find com.android.tools.build:gradle:3.0.1" in React Native

Hey there, I’ve run into this exact headache before when working with older React Native projects. Let’s break down what’s going wrong and fix it step by step:

What’s the core issue?

The com.android.tools.build:gradle:3.0.1 dependency isn’t reliably available in JCenter anymore. Google moved their Android build tools to their dedicated repository, so your project isn’t looking in the right places to grab this package.

Step 1: Update your root build.gradle file

Open the build.gradle file in your project’s root directory (not the one inside the app folder). Modify the buildscript > repositories section to prioritize Google’s repository and Maven Central over JCenter:

buildscript {
    repositories {
        google() // Add this first to prioritize Google's repo
        mavenCentral() // Then add Maven Central
        jcenter() // You can keep this, but it should come after the above two
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        // Leave other dependencies (like React Native's classpath) as-is
    }
}

allprojects {
    repositories {
        mavenLocal()
        google() // Add this here too
        mavenCentral() // And this
        jcenter()
        maven {
            // React Native binaries are pulled from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

Step 2: Check your Gradle wrapper version

Gradle plugin 3.0.1 requires a matching Gradle wrapper version (at least 4.1). Open gradle/wrapper/gradle-wrapper.properties and confirm the distributionUrl points to the right version:

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

If it’s set to an older version (like 3.x), update it to the line above.

Step 3: Clean and rebuild the project

Once you’ve made those changes, clear the old build cache and restart the Android build:

# Move to the android directory
cd android
# Clean existing build files
./gradlew clean
# Go back to root and run the project
cd ..
react-native run-android

If you’re still stuck (common for restricted network regions)

If you’re hitting network blocks, add a domestic Maven mirror (like Alibaba’s) to your root build.gradle to improve access to dependencies:

buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        google()
        mavenCentral()
        jcenter()
    }
    // ... rest of the buildscript block
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
        // ... rest of the allprojects block
    }
}

That should resolve the dependency not found error and get your React Native project running on the Android emulator smoothly.

内容的提问来源于stack exchange,提问作者Joseph Wu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:08:06