【问题标题】:Cannot resolve google play services version 15.0.2无法解析 google play services 版本 15.0.2
【发布时间】:2018-05-10 17:02:36
【问题描述】:

当我想安装 Google play services 15.0.2 时(因为 15.0.0 创建 dexing 错误我不知道为什么)我从 gradle 收到这些错误:

Failed to resolve: com.google.android.gms:play-services-location:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog


Failed to resolve: com.google.android.gms:play-services-basement:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog


Failed to resolve: com.google.android.gms:play-services-tasks:15.0.2
Install Repository and sync project
Open File
Show in Project Structure dialog

但我从未将这些依赖项放在任何 build.gradle 中。 如果我想使用安装按钮进行安装,则会出现错误: 找不到依赖项

这是我的 build.gradle 文件:

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION             = 25
def DEFAULT_BUILD_TOOLS_VERSION             = "25.0.2"
def DEFAULT_TARGET_SDK_VERSION              = 25
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "15.0.2"

android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? 
project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion project.hasProperty('buildToolsVersion') ? 
project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 
project.hasProperty('buildToolsVetargetSdkVersionrsion') ? 
project.buildToolsVersion : DEFAULT_TARGET_SDK_VERSION
    versionCode 1
    versionName "1.0"
}
}

repositories {
mavenCentral()
}

dependencies {
    def googlePlayServicesVersion = 
project.hasProperty('googlePlayServicesVersion') ? 
project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.facebook.react:react-native:+'
    compile "com.google.firebase:firebase-core:$googlePlayServicesVersion"
    compile "com.google.firebase:firebase-messaging:$googlePlayServicesVersion"
    compile 'me.leolin:ShortcutBadger:1.1.17@aar'
}

编辑: 我成功解决了我的问题。 实际上,我的父 build.gradle 中有一个 multidex 脚本,它强制将我的所有 com.gms.google 更新为 15.0.2,但正如你所说,谷歌播放服务没有 15.0.2。 我刚刚删除了这个脚本,它工作了

【问题讨论】:

标签: android firebase android-gradle-plugin build.gradle


【解决方案1】:

Firebase 库现在有独立的版本,而不是之前共享的相同版本。见here。 所以这目前可行,但将来可能会有所不同:

implementation "com.google.firebase:firebase-core:$googlePlayServicesVersion"
implementation "com.google.firebase:firebase-messaging:$googlePlayServicesVersion"

更重要的是,firebase 库不再与 google play services 的版本相同,没有位置等播放服务库的 15.0.2 版本,请参阅here,最新的是 15.0.0。

我的建议是单独定义每个库。

为了解决你的问题,改变这个:

def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "15.0.0"

还有这个:

implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-messaging:15.0.2"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-18
    • 2018-03-07
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 2018-11-06
    • 2018-12-02
    相关资源
    最近更新 更多