React-native-onesignal: 已解析的 Google Play 服务库依赖项依赖于另一个确切版本(例如“[10.2.1, 16.0.99]”,但未解析为该版本。

创建于 2019-12-17  ·  17评论  ·  资料来源: OneSignal/react-native-onesignal

描述:

我按照文档安装了 react-native-onesignal 。 它在 iOS 上运行良好,但在 android 端导致与 Google Play 服务依赖项相关的构建问题。 如果我将 google-services 从 4.2.0 降级到 4.1.0,它似乎确实会通过,但不幸的是,降级会破坏我的其他几个依赖项。

我已经在 android 端的几个地方看到了这个问题,这让我相信这个 react-native 库支持的最新版本的 android SDK 存在问题:

https://github.com/OneSignal/OneSignal-Android-SDK/issues/894
https://stackoverflow.com/questions/59128152/error-in-project-app-a-resolved-google-play-services-library-dependency-depen

这是我收到的错误:

> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
  1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.onesignal:OneSignal:3.12.3 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], b
  ut play-services-location version was 15.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:play-services-location@{strictly 15.0.1}
  -- Project 'app' depends onto com.onesignal:OneSignal@{strictly 3.12.3}
  -- Project 'app' depends on project 'react' which depends onto com.onesignal:[email protected]

环境

  1. react-native-onesignal 版本 3.6.0
  2. 纱线和反应原生链接

重现问题的步骤:

  1. 使用yarn安装OneSignal SDK到项目中
  2. 将 google-services 版本 4.2.0 和 onesignal-gradle-plugin 用于 gradle 构建脚本:
buildscript {
  ...
  repositories {
    ...
    maven {
            url 'https://plugins.gradle.org/m2/'
        }
  }
  dependencies {
    ...
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    classpath 'com.google.gms:google-services:4.2.0'
  }
}
  1. 在构建脚本之后应用 gradle 插件
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
  1. 尝试构建启动 android 应用程序
react-native run-android

还要别的吗:

Help Wanted

最有用的评论

尝试在 androidappbuild.gradle 中的 google-services 之前声明 onesignal-gradle-plugin:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'

所有17条评论

我也遇到了同样的问题。

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
  1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.onesignal:OneSignal:3.12.3 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], b
  ut play-services-location version was 16.0.0.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:play-services-location@{strictly 16.0.0}
  -- Project 'app' depends onto com.onesignal:OneSignal@{strictly 3.12.3}
  -- Project 'app' depends on project 'react' which depends onto com.onesignal:[email protected]

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
  uild.gradle file.

* 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 15s

@Esirei您使用的是什么版本的 react-native-onesignal?

3.6.1 上的相同问题:

* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[10.2.
  1, 16.0.99]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.onesignal:OneSignal:3.12.4 -> com.google.android.gms:play-services-location@[10.2.1, 16.0.99], b
  ut play-services-location version was 15.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:play-services-location@{strictly 15.0.1}
  -- Project 'app' depends onto com.onesignal:OneSignal@{strictly 3.12.4}
  -- Project 'app' depends on project 'react' which depends onto com.onesignal:[email protected]

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
  uild.gradle file.

降级到 3.4.2 为我解决了这个问题。

你能确保你有最新版本的 OneSignal Gradle 插件吗?

@rgomezp我尝试安装最新的 onesignal 版本,其中包括 3.12.4 版本的 OneSignal gradle 插件。 但是,这仍然引发了错误

似乎 3.12.* Android SDK 与 google-services 4.2 不兼容。

尝试在 androidappbuild.gradle 中的 google-services 之前声明 onesignal-gradle-plugin:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'

正如@allumina上面所说,您必须根据文档编辑 appbuild.gradle 文件。

@Esirei您使用的是什么版本的 react-native-onesignal?

v3.6.1

早些时候,将 onesignal-gradle-plugin 添加到 gradle 文件步骤是不存在的。 我认为在升级时,这导致它无法编译。 添加那些修复了我的问题。

这似乎暂时解决了。 感谢大家的参与

@rgomezp我不相信这是固定的。 这里的每个人都找到了解决方法,例如降级。 我相信这仍然是一个很大的问题。

除了“请确保您安装最新版本”之外,我没有看到 OneSignal 的任何回复,这没有帮助。

@rgomezp我尝试安装最新的 onesignal 版本,其中包括 3.12.4 版本的 OneSignal gradle 插件。 但是,这仍然引发了错误

似乎 3.12.* Android SDK 与 google-services 4.2 不兼容。

@cmcaboy OneSignal Gradle 插件是独立于OneSignal Android Native SDK的组件,不会自动包含在内。
请仔细检查您是否正确遵循了 React Native OneSignal 设置指南中的添加 Gradle 插件部分。

尝试在 androidappbuild.gradle 中的 google-services 之前声明 onesignal-gradle-plugin:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'

谢谢它对我有用。

在 app/build.gradle 中,我添加了这一行:
插件{
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' 版本 '0.12.6'
}

尝试在 androidappbuild.gradle 中的 google-services 之前声明 onesignal-gradle-plugin:

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'

@allumina
为我工作。 谢谢

应用插件:'com.onesignal.androidsdk.onesignal-gradle-plugin'
应用插件:'com.google.gms.google-services'

@allumina
为我工作。 谢谢☺️👍

我仍然遇到这个问题,上述解决方案对我不起作用,任何人都可以分享他/她的整个 gradle 文件吗?

此页面是否有帮助?
0 / 5 - 0 等级