安装和实施React Native设备信息时出错

时间:2018-12-13 03:25:34

标签: 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

```

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

1 个答案:

答案 0 :(得分:1)

将此块添加到app/build.gradle块下面的buildTypes{}文件中,然后再次运行该应用程序

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