代码之家  ›  专栏  ›  技术社区  ›  Psyycker

无法解析google play services版本15.0.2

  •  3
  • Psyycker  · 技术社区  · 6 年前

    当我想安装Google play services 15.0.2(因为15.0.0创建了一个索引错误,我不知道为什么)时,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
    

    但我从未在任何构建中放置这些依赖项。格拉德尔。 如果要使用install(安装)按钮进行安装,则会出现以下错误: 找不到依赖项

    这是我的身材。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'
    }
    

    编辑: 我成功地解决了我的问题。 实际上,我在父构建中有一个多索引脚本。gradle强制更新了我所有的com。gms。google的版本是15.0.2,但正如你所说,google play服务没有15.0.2。 我刚刚删除了这个脚本,它成功了

    1 回复  |  直到 6 年前
        1
  •  2
  •   ADM    6 年前

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

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

    更重要的是,firebase LIB不再具有与google play services相同的版本,play services库(如location)没有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"