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

执行react-native run-android提示BUILD FAILED,求助问题排查与解决

Fixing React Native Android Build Failure: Missing android.arch.lifecycle:runtime:1.0.0

Hey there, let’s work through this build issue together. The error you’re seeing—missing the android.arch.lifecycle:runtime:1.0.0 artifact when building react-native-device-info—is almost certainly tied to outdated dependencies or repository configuration, since jcenter (where that old artifact was hosted) has been sunset and no longer serves many older packages. Here are the most effective fixes to try:

1. Upgrade react-native-device-info to a newer version

Older versions of this library rely on deprecated Android Architecture Components that are no longer available on jcenter. Upgrading to a modern version will resolve this dependency mismatch:

  • Run this command in your project root:
    npm install react-native-device-info@latest --save
    
    If you’re on an older React Native version (pre-0.60), check the library’s release notes to pick a compatible version (v5.x or later works for RN 0.60+).

2. Clear Gradle’s cached dependencies

Corrupted or outdated local cache can cause Gradle to fail finding valid artifacts. Let’s reset it:

  1. Navigate to your Android directory:
    cd android
    
  2. Clean the build and refresh dependencies:
    ./gradlew clean
    ./gradlew build --refresh-dependencies
    
  3. (Optional) For a deeper clean, delete your global Gradle cache:
    • On Mac/Linux: Remove the ~/.gradle/caches folder
    • On Windows: Remove the C:\Users\<YourUsername>\.gradle\caches folder

3. Update your project’s repository configuration

Since jcenter is no longer maintained, ensure your project uses active repositories like mavenCentral and Google’s repo. Open android/build.gradle and update the allprojects -> repositories block:

allprojects {
    repositories {
        google()
        mavenCentral()
        // Keep jcenter only if you have other dependencies that still require it
        jcenter() {
            content {
                excludeGroup("android.arch")
            }
        }
    }
}

This prioritizes active repos and excludes the problematic arch group from jcenter.

4. Verify Android SDK setup

Let’s rule out SDK-related issues:

  • Open Android Studio, go to Tools > SDK Manager
  • Ensure you have the Android SDK Build-Tools version specified in your android/build.gradle (check the buildToolsVersion value) installed
  • If you’re migrating to AndroidX, make sure you have the AndroidX Repository installed under the SDK Tools tab

5. Enable AndroidX and Jetifier (if not already using)

If your project still uses the old Support Library, enabling AndroidX and Jetifier will automatically migrate third-party dependencies to use modern AndroidX libraries:

  1. Open android/gradle.properties
  2. Add or ensure these lines are present:
    android.useAndroidX=true
    android.enableJetifier=true
    
  3. Re-run the build after saving these changes

After trying these steps, run react-native run-android again—this should resolve the missing dependency error and get your app building again.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 07:33:11