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

找不到任何与com.google.android.gms匹配的版本:播放服务库:[15.0.1,16.0.0)

  •  13
  • Riddhi  · 技术社区  · 7 年前

    我正在为我的Android应用程序使用FireBase,当我试图运行该应用程序时,突然出现了一个错误。星期六它工作得很好。我不知道这个错误是如何发生的,也不知道如何解决这个问题。请帮帮我。

    我的build.gradle中的依赖项

    dependencies {
        compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
            transitive = true;
        }
        compile 'com.android.volley:volley:1.0.0'
        compile 'com.android.support:appcompat-v7:23.4.0'
        compile 'com.android.support:cardview-v7:23.4.0'
        compile 'com.facebook.android:facebook-android-sdk:4.1.0'
        compile 'com.google.code.gson:gson:2.8.4'
        compile 'com.android.support:multidex:1.0.3'
        compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
        compile 'com.mixpanel.android:mixpanel-android:4.8.0'
        compile 'com.firebase:firebase-client-android:2.4.0'
    
        compile 'com.google.firebase:firebase-core:16.0.0'
        compile 'com.google.firebase:firebase-auth:16.0.1'
        compile 'com.android.support:support-v4:23.4.0'
        compile 'com.android.support:design:23.4.0'
        compile 'com.j256.ormlite:ormlite-android:4.48'
        compile 'com.j256.ormlite:ormlite-core:4.48'
        compile 'com.android.support:recyclerview-v7:23.4.0'
        compile 'com.github.tibolte:elasticdownload:1.0.+'
        compile 'me.dm7.barcodescanner:zxing:1.8.4'
        compile 'com.google.android.gms:play-services-vision:15.0.2'
        compile 'com.android.support.constraint:constraint-layout:1.1.1'
        compile 'com.github.amlcurran.showcaseview:library:5.4.3'
        compile 'com.wang.avi:library:2.1.3'
        testCompile 'junit:junit:4.12'
        androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.6.0'
        androidTestCompile 'com.android.support.test:rules:1.0.2'
    }
    apply plugin: 'com.google.gms.google-services'
    

    在我的项目级build.gradle中:

    dependencies {
            classpath 'com.android.tools.build:gradle:2.2.2'
            classpath 'com.google.gms:google-services:4.0.0'
        }
    

    我得到的错误:

    找不到任何与com.google.android.gms匹配的版本:播放服务库:[15.0.1,16.0.0]。

    9 回复  |  直到 6 年前
        1
  •  16
  •   mpontus    7 年前

    确保你有 google() 项目级build.gradle中的存储库优先于任何其他存储库:

    allprojects {
        repositories {
            google()
            mavenLocal()
            jcenter()
        }
    }
    
        2
  •  7
  •   jjz    7 年前

    更新后我遇到了同样的问题。尝试验证您是否安装了最新的构建工具和Google知识库版本。

    此外,请验证您正在使用的项目的版本。检查完 build.grade 后,尝试重新同步、清理和重新构建项目。

    如果需要,请尝试更新到项目依赖项的最新版本。

    buildscript{
    
    存储库{
    jcenter()。
    谷歌(
    }
    依赖项{
    类路径'com.android.tools.build:gradle:3.1.3'
    }
    //……
    }
    
    所有项目{
    存储库{
    谷歌(
    jcenter()。
    }
    }
    
    任务清理(类型:删除){
    删除rootproject.builddir
    }
    
    enter image description here

    同时,验证项目的build.gradle你正在使用的google()以及生成工具版本.在检查完建筑.gradle,尝试重新同步、清理和重新构建项目。

    如果需要,请尝试更新到项目依赖项的最新版本。

    buildscript {
    
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
        }
        // ...
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    
        3
  •  5
  •   Gautam Surani    7 年前

    在build.gradle中添加此行

    apply plugin: 'com.google.gms.google-services'
    // Work around for onesignal-gradle-plugin compatibility
    com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
    
        4
  •  2
  •   Erfan    6 年前

    在我的例子中,我只是更新了 android sdk platform tools previous was 28.0.0 when I updated it to 28.0.1 problem fix!

    enter image description here

        5
  •  1
  •   teteArg    6 年前

    我用这个版本解决了这个问题。

    buildscript {
        ext.kotlin_version = '1.2.30'
        repositories {
            google()
            jcenter()
            maven {
                url 'https://dl.bintray.com/android/android-tools'
            }
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.2.0'
        }
    }
    
        6
  •  1
  •   Messou    6 年前
        implementation 'com.google.firebase:firebase-core:16.0.1'
        implementation 'com.google.firebase:firebase-database:16.0.1'
        implementation 'com.google.android.gms:play-services-auth:16.0.1'
    }
    
    apply plugin: 'com.google.gms.google-services'
    com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
    
        7
  •  0
  •   Mir-Ismaili    6 年前

    构建->清理项目

    在我的特殊情况下就足够了 通用汽车公司: v15.0.1 耐火材料: v16.0.1 )。

        8
  •  0
  •   WIT_NGU    6 年前

    突然之间,在我的项目中没有任何变化,我的错误就降到了下面。

    错误:无法解析“:app@debug/compileclasspath”的依赖项:无法解析com.google.android.gms:播放服务位置:[15.0.0,16.0.0)。

    在项目级build.gradle中

    buildscript {
        ext.kotlin_version = '1.3.21'
        repositories {
            google()
            jcenter()
            maven {
                url 'https://dl.bintray.com/android/android-tools'
            }
        }
    dependencies {
            classpath 'com.android.tools.build:gradle:3.3.2'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.2.0'
        }
    

    allprojects {
        repositories {
            google()
            mavenCentral()
            jcenter()
            maven { url 'https://google.bintray.com/exoplayer/' }
        }
    }
    

    有了以上的设置,我没有运气。

    下面是对我有用的 我发现问题出在一个信号上

    我在依赖项中添加了排除子句:

    implementation ('com.onesignal:OneSignal:3.10.5') {
        exclude group: 'com.google.android.gms'
    }
    

    然后手动添加缺少的依赖项。 添加exclude子句后,我无法解析com.google.firebase:firebase消息[10.2.1,12.1.0]。如果您发现任何其他缺少的依赖项,请按照下面的步骤操作。

    在模块级build.gradle中,我替换了

    implementation 'com.google.firebase:firebase-messaging:17.4.0' with
    implementation 'com.google.firebase:firebase-messaging:10.2.1'
    

    最终构建成功。我为此浪费了将近5个小时。希望这对某些人有帮助。

        9
  •  -1
  •   Messou    6 年前

    build.gradle(应用程序)

    apply plugin: 'com.google.gms.google-services'
    com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true