我正在尝试将OneSignal集成到我的项目中,但这会导致Google Play服务出错。
这是我的build.gradle
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
dependencies {
...
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.3.0"
implementation "com.google.android.gms:play-services-plus:15.0.1"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-places:15.0.1"
implementation "com.google.android.gms:play-services-wallet:15.0.1"
...
}
apply plugin: 'com.google.gms.google-services'
现在,我添加了OneSignal。
buildscript {
...
dependencies {
...
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
...
}
}
这是我更新的build.gradle
:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
dependencies {
...
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.3.0"
implementation "com.google.android.gms:play-services-plus:15.0.1"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"
implementation "com.google.android.gms:play-services-places:15.0.1"
implementation "com.google.android.gms:play-services-wallet:15.0.1"
...
implementation 'com.onesignal:OneSignal:3.9.1'
...
}
apply plugin: 'com.google.gms.google-services'
现在,与此同步将导致错误:
Failed to resolve: com.google.firebase:firebase-core:17.3.0
...
Failed to resolve: com.google.android.gms:play-services-plus:17.3.0
...
Failed to resolve: com.google.android.gms:play-services-auth:17.3.0
...
由于某种原因,添加OneSignal会导致Google Play服务升级到我的firebase-messaging
版本(17.3.0)
有什么办法可以解决这个问题?谢谢。
答案 0 :(得分:2)
尝试使用版本范围,并在项目级别的gradle中替换它
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
以及应用程序级别gradle依赖项
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
此外,您还拥有oneSignal ID(来自您当前发布的gradle的想法) 还要添加check here
完成syn清理并重建项目选项后,即可完成
答案 1 :(得分:0)
您还需要在顶级build.gradle中使用最新版本的Google Play服务插件:
classpath 'com.google.gms:google-services:4.1.0'
答案 2 :(得分:0)
一个Signal在内部处理firebase的依赖项。为什么在应用gradle中使用firebase依赖关系?删除它们并重建。
删除它们
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.3.0"
答案 3 :(得分:0)
您需要使用最新版本的Firebase依赖项,
uname
尝试一下。
答案 4 :(得分:-3)
尝试添加Google存储库
repositories {
jcenter()
google()
...
}