React Native应用运行失败:':react-native-fast-image'项目配置错误修复指导请求
Hey, let's break down what's going wrong here and fix it step by step.
Your core issues are two-fold:
- JCenter is no longer maintained and its SSL certificate has expired — that's why you're seeing those
PKIX path validation failederrors when trying to pull Kotlin dependencies from it. - The
react-native-fast-imagepackage you're using relies on an outdated Gradle plugin (3.4.0) that's incompatible with newer Gradle versions like 7.0.
Here's how to fix this:
Step 1: Replace JCenter with active repositories
First, update your project's repository sources to use maintained alternatives like Maven Central and Google's repository:
- Go to your project root's
build.gradlefile (not the one inside theappfolder) - Find the
allprojects > repositoriesblock and replace anyjcenter()entries withmavenCentral(), making suregoogle()is included too:allprojects { repositories { google() mavenCentral() mavenLocal() maven { url "$rootDir/../node_modules/react-native/android" } // Keep any other necessary repositories (like for other native packages) } } - You'll also need to check the
react-native-fast-imagemodule's build config. Navigate tonode_modules/react-native-fast-image/android/build.gradleand update itsrepositoriessection the same way — removejcenter()and addmavenCentral()+google().
Step 2: Upgrade react-native-fast-image to a modern version
The old version of react-native-fast-image uses a deprecated Gradle plugin. Upgrading it will resolve compatibility issues:
Run this command in your project root:
# Using npm npm install react-native-fast-image@latest --save # Or using yarn yarn add react-native-fast-image@latest
After upgrading, clean your build cache and rebuild:
npx react-native clean npx react-native run-android
Step 3: Fix PKIX certificate issues (if still present)
If you still see certificate errors after switching repositories, try these:
- Update your JDK: Use a recent JDK version (11 or newer) — older versions might lack up-to-date SSL certificates.
- Temporary insecure access (dev only): If you're in a development environment and need a quick fix, allow insecure protocol for Maven Central in your Gradle config (don't do this for production):
repositories { mavenCentral { url "https://repo1.maven.org/maven2/" allowInsecureProtocol = true } }
Step 4: Upgrade your project's Gradle (optional but recommended)
To avoid future compatibility issues, upgrade your project's Gradle version to match modern standards:
- Open
gradle/wrapper/gradle-wrapper.propertiesand update the distribution URL:distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip - Open your root
build.gradleand update the Android Gradle plugin version to match (7.4.2 works with Gradle 7.5):dependencies { classpath "com.android.tools.build:gradle:7.4.2" // If you use Kotlin, upgrade the kotlin-gradle-plugin to a compatible version too }
After following these steps, your build should resolve the dependency issues and run successfully.
内容的提问来源于stack exchange,提问作者my account

