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

React Native多库包名冲突致react-native-device-info构建失败求助

Hey there, let's work through these two React Native project issues you're hitting:

问题1:存在多个包名为react native的库

This usually happens when your dependencies have conflicting versions or duplicate entries of React Native-related packages. Here's how to fix it:

  • Clean your project cache first: Run npx react-native start --reset-cache to clear the Metro bundler cache. Then delete the node_modules folder and lock file with rm -rf node_modules package-lock.json yarn.lock (adjust for Windows: rmdir /s node_modules and delete the lock files manually).
  • Audit your package.json: Check for duplicate entries of packages like react-native or any related libraries. Make sure you only have one declared version of react-native in your dependencies.
  • Reinstall dependencies: Run npm install or yarn install based on your package manager, then rebuild your project with npx react-native run-android (or iOS if needed).
问题2::react-native-device-info:processReleaseResources失败(多com.google.android.gms.license库冲突)

This conflict typically arises because different native dependencies are pulling in different versions of Google Play Services libraries. Try these steps:

  • Force a unified Google Play Services version: Add this to your android/build.gradle file under the allprojects block, replacing the version with the one compatible with your project:
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'com.google.android.gms') {
                    details.useVersion '17.0.0' // Use the version that works for your setup
                }
            }
        }
    }
    
  • Exclude conflicting dependencies from react-native-device-info: If forcing the version doesn't work, modify your android/app/build.gradle to exclude the conflicting license library from the package:
    implementation(project(':react-native-device-info')) {
        exclude group: 'com.google.android.gms', module: 'license'
    }
    
  • Clean Gradle caches: Run cd android && ./gradlew clean && ./gradlew build --refresh-dependencies to wipe old Gradle artifacts and refresh dependencies.
  • Update react-native-device-info: Make sure you're using the latest stable version of the package, as newer versions often fix dependency conflicts. Run npm update react-native-device-info or yarn upgrade react-native-device-info.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:36:25