javascript - 安装和实现 react native 设备信息时出错

标签 javascript node.js reactjs react-native

我正在尝试将 react-native-device-info 集成到我的项目中,当我安装模块并链接它时,会出现如下错误

```

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.google.android.gms:play-services-base' has different version for the compile (15.0.1) and runtime (16.0.1) classpath. You should manually set the same version via DependencyResolution

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
13 actionable tasks: 1 executed, 12 up-to-date

```

当我手动配置项目时,会出现相同的错误。但是当我取消链接 react native 设备信息时,项目运行良好。

最佳答案

将此 block 添加到 app/build.gradle 文件中的 buildTypes{} block 下方并再次运行应用

configurations.all {
    resolutionStrategy {
           force 'com.google.android.gms:play-services-base:16.0.1'
    }
}

关于javascript - 安装和实现 react native 设备信息时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53754594/

相关文章:

javascript - 如何在 React 中渲染 `HTMLCanvasElement`?

javascript - Redux-form:如何在向导表单上设置初始值?

javascript - AJAX+Rails 点击处理程序未绑定(bind)

javascript - 环境变量 - 未定义

javascript - 从不同地方取消setInterval(NodeJS变量范围)

javascript - 查找 2 id 在 Mongoose 数组中的位置

node.js - Puppeteer:如何在没有 CSS/JS/fonts/images 的情况下只加载 html?

node.js - 分段上传node.js aws-sdk中的AWS s3进度条

javascript - Internet Explorer 中 'script' 标记的“onload”处理程序

javascript - 如何在点击图片后加载<iframe>以提高性能?