【问题标题】:Gradle could not find dependency com.google.android.gms:play-servicesGradle 找不到依赖项 com.google.android.gms:play-services
【发布时间】:2018-08-01 07:13:31
【问题描述】:

自从我将 Android Studio 升级到 3.0.0 后,我遇到了一个问题:我再也找不到 com.google.android.gms:play-services了!

添加此依赖项后,当我尝试同步我的项目时,我收到此消息:

Failed to resolve: com.google.android.gms:play-services-games:11.4.2

我可以单击“安装存储库并同步项目”,但是当我这样做时,我会收到以下消息:

Could not find dependency "com.google.android.gms:play-services-games:11.4.2"

我尝试搜索,但找到的唯一解决方案是安装 Google 存储库,并将 jcenter() 添加到我的 build.gradle 文件中的存储库中 但我已经这样做了!

有什么想法吗?

这是我的 build.gradle 文件:

buildscript {


    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1'


    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "Glowee"
        gdxVersion = '1.9.7'
        roboVMVersion = '2.3.1'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"

    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"

        compile "com.google.android.gms:play-services-games:11.4.2"
        compile "com.google.android.gms:play-services-ads:11.4.2"
        compile "com.google.android.gms:play-services-plus:11.4.2"

    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"


    dependencies {
        compile project(":core")
        compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
        compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"

        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"

    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"

        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"

    }
}

tasks.eclipse.doLast {
    delete ".project"
}

【问题讨论】:

标签: android gradle dependencies google-play-services android-studio-3.0


【解决方案1】:

我通过在 build.gradle 项目模块中添加 google() 存储库解决了这个问题

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
  • 我附上了我的 Project Build Gradle 的截图。就这样 。他需要做的就是在存储库{}中添加“google()”,这就是屏幕截图所告诉的(或我是如何实现的)这是一个指向 imgur 的链接,这就是 @Saranjith
  • 我有这个问题,我的存储库中有google()
  • @SalmanSeifian 将 google() 放在第一行,在 jcenter() 之前
【解决方案2】:

我遇到了同样的问题,我通过在 build.gradle 项目模块中添加 google() 存储库来解决它

【讨论】:

    【解决方案3】:

    我尝试使用 'google()' 但它不起作用,阅读了 AndroidStudio 的一些建议我发现要解决这个问题我必须手动修改 build.gradle 文件升级 compileSdkVersion、minSdkVersion 等......我猜问题出现是因为我使用的东西与我拥有的 minSdkVersion 不兼容。

    【讨论】:

      猜你喜欢
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      • 2015-04-23
      • 1970-01-01
      • 1970-01-01
      • 2016-03-17
      相关资源
      最近更新 更多