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

安装rn-fetch-blob后React Native 0.62.2安卓构建失败求助

Fixing React Native 0.62.2 Build Failure After Installing rn-fetch-blob

Hey there, let's work through this build failure together. The "无法删除目录" (failed to delete directory) error in the :app:processDebugResources task usually ties to cached build files, process locks, or compatibility mismatches between rn-fetch-blob, your Gradle version, and JDK setup. Here are the steps to resolve it:

Step 1: Clean Up Build Caches and Dependencies

First, let's wipe out any corrupted cached files and reinstall dependencies:

  • Stop all running processes related to your project: close the Android emulator, shut down the Metro bundler, and end any Java/Gradle processes in your task manager.
  • Run these commands in your project root:
    # Navigate to Android directory
    cd android
    # Clean Gradle build files
    ./gradlew clean
    # Go back to root
    cd ..
    # Remove node modules and lock file
    rm -rf node_modules
    rm package-lock.json
    # Reinstall dependencies
    npm install
    
    For Windows users, use these commands instead:
    cd android
    gradlew clean
    cd ..
    rmdir /s /q node_modules
    del package-lock.json
    npm install
    

Step 2: Verify rn-fetch-blob Version Compatibility

React Native 0.62.2 is an older version, so not all rn-fetch-blob releases will work smoothly with it. Try downgrading to a version known to be compatible, like v0.12.0:

  • Update your package.json to set "rn-fetch-blob": "^0.12.0"
  • Run npm install again, then retry react-native run-android

Step 3: Release Locked Directories

The "无法删除目录" error often happens because a system process is holding onto files in your Android build folder. To fix this:

  • Windows: Open Task Manager, go to the "Details" tab, look for any java.exe or gradlew.exe processes related to your project, and end them.
  • Mac/Linux: Use the lsof command to find the process locking the directory (replace <path-to-build-dir> with your actual android/app/build path):
    lsof | grep <path-to-build-dir>
    
    Then kill the process using its PID:
    kill -9 <PID>
    

Step 4: Adjust JDK and Gradle Setup

React Native 0.62.x officially recommends JDK 8 or 11, and JDK 13 might have compatibility issues with Gradle 6.3. Try switching to JDK 11:

  • Install JDK 11 and update your system's JAVA_HOME environment variable to point to the JDK 11 installation.
  • Double-check that your android/gradle/wrapper/gradle-wrapper.properties file has distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip to match your local Gradle version.

Step 5: Verify rn-fetch-blob Linking

While React Native 0.60+ uses auto-linking, sometimes manual linking can resolve hidden issues. Run this command to ensure rn-fetch-blob is properly linked:

react-native link rn-fetch-blob

Then run ./gradlew clean again before rebuilding.

If none of these steps work, try creating a fresh React Native 0.62.2 project, install rn-fetch-blob, and test the build. This will help you rule out any custom configuration issues in your original project.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 08:52:45