简体   繁体   English

无法解析 ':app@debug/compileClasspath' 的依赖:无法解析 com.google.android.gms:play-services-basement:[15.0.0,16.0.0)

[英]Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-basement:[15.0.0,16.0.0)

I am getting this error: Here is my build.gradle(Module:app)我收到此错误:这是我的 build.gradle(Module:app)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.mycompany.myapp"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding.enabled = true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.0'
    compileOnly "org.projectlombok:lombok:1.16.20"
    annotationProcessor 'org.projectlombok:lombok:1.16.20'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.0'
    implementation 'com.google.android.gms:play-services-location:15.0.0'
    implementation 'com.google.android.gms:play-services-places:15.0.0'
    implementation 'com.paytm.pgsdk:pgsdk:1.0.8'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}

apply plugin: 'com.google.gms.google-services'

and Here is my build.gradle(Project: myApp)这是我的 build.gradle(Project: myApp)

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'io.fabric.tools:gradle:1.25.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

I have checked other solutions, most of them suggest to add我检查了其他解决方案,其中大多数建议添加

maven { url "https://maven.google.com" }

to build.gradle of project.到项目的 build.gradle。 I have already tried this but I am still getting same error.我已经尝试过这个,但我仍然遇到同样的错误。

I am on android studio 3.0.我在 android studio 3.0 上。 I have also tried adding google() instead of maven (another suggestion)我也尝试添加google()而不是 maven(另一个建议)

OPTION 1:选项1:

Follow the below instruction to resolve it.请按照以下说明解决。

Project-level build.gradle项目级 build.gradle

use

maven { url "https://www.jitpack.io" }

instead of代替

maven { url "https://jitpack.io" }

OPTION 2:选项 2:

Project-level build.gradle项目级 build.gradle

google() repository should be 1st priority google()存储库应该是第一优先级

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
    }
}

OPTION 3:选项 3:

Follow the below steps to resolve it.请按照以下步骤解决。

Step1:第1步:

Project-level build.gradle项目级 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        maven { url "https://jitpack.io" } // For Ucrop
        maven { url "https://maven.google.com" } // Google's Maven repository - FCM
        maven {
            url 'https://dl.bintray.com/azeesoft/maven'
        }
        google()
        jcenter()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Step2:第2步:

App-level build.gradle应用级 build.gradle

I have update One Signal version.我有更新 One Signal 版本。

use

implementation 'com.onesignal:OneSignal:3.11.1'

instead of代替

implementation 'com.onesignal:OneSignal:3.10.9' 

转到文件 → 其他设置 → 默认设置 → 构建、执行、部署 → 构建工具 → Gradle → 取消选中Offline work选项。

I had the same issue while use OneSignal to handle push notifications in my android application.我在使用 OneSignal 处理我的 android 应用程序中的推送通知时遇到了同样的问题。

The solution is to add the exclude clause to its' dependency:解决方案是将 exclude 子句添加到其依赖项中:

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

in the app folder, then add any other missing dependency manually such as:在 app 文件夹中,然后手动添加任何其他缺少的依赖项,例如:

implementation 'com.google.android.gms:play-services-appinvite:16.1.0'

The problem is that OneSignal SDK contains Google Play Service dependency that are not of the same version with the latest version of gms and firesbase I used in the app.问题是 OneSignal SDK 包含的 Google Play 服务依赖项与我在应用程序中使用的最新版本的 gms 和 firesbase 的版本不同。

So I suggest you figure out a dependency you added that uses google play service in the project and use the exclude clause on it.所以我建议你找出你添加的一个在项目中使用 google play 服务的依赖项,并在其上使用 exclude 子句。 Though your gradle should build if your system is connected to the internet.尽管如果您的系统连接到互联网,您的 gradle 应该会构建。

Hope this is helpful.希望这是有帮助的。

I was using a VPN for internet connection.我正在使用 VPN 进行互联网连接。 I closed VPN and it worked for me.我关闭了 VPN,它对我有用。

If you have it declared as follows in project build.gradle 如果您在项目build.gradle中声明了以下内容

maven { url "https://jitpack.io" }

try changing to 尝试更改为

maven { url "https://www.jitpack.io" }

使用 VPN 解决了​​我的问题。

I had this problem and I was using a proxy before.我遇到了这个问题,我以前使用过代理。 I figured out that my proxy is not working any more so i went to settings and changed the proxy config to Automatic but still the same error was being shown.我发现我的代理不再工作,所以我去设置并将代理配置更改为自动,但仍然显示相同的错误。

I finally found that the proxy was also automatically set to gradle as well but when I disabled it, it wasn't removed from my gradle config.我终于发现代理也自动设置为 gradle,但是当我禁用它时,它并没有从我的 gradle 配置中删除。 so I went to C:Users/User/.gradle/gradle.properties and in that file there was something like this:所以我去了C:Users/User/.gradle/gradle.properties并且在那个文件中有这样的东西:

## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#enter code here
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Aug 31 18:23:27 IRDT 2019
systemProp.https.proxyPort=8118
systemProp.http.proxyHost=fodev.org
systemProp.https.proxyHost=fodev.org
systemProp.http.proxyPort=8118

so I just edited this file and commented the last 4 lines and it solved my problem.所以我只是编辑了这个文件并评论了最后 4 行,它解决了我的问题。

I am also using a VPN service.我也在使用 VPN 服务。

My issue was...我的问题是...
I can run the project... but suddenly this error came up.我可以运行该项目...但突然出现此错误。
After few tried "Try Again" Solution but not solving.经过几次尝试“再试一次”解决方案但没有解决。

Finally after few minutes wasted.终于过了几分钟就白费了。 I Try Clean Project.我尝试清洁项目。 And Rebuild.和重建。 Tadaaaa it work. Tadaaaa它的工作。
i dont know if this will help anybody but it solve my issue.我不知道这是否会帮助任何人,但它解决了我的问题。 hope it solve yours.希望它能解决你的问题。

Open top-level build.gradle file and add google-services:打开顶级 build.gradle 文件并添加 google-services:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

also if you already have it added simply update google-service and gradle to the latest此外,如果您已经添加了它,只需将 google-service 和 gradle 更新到最新

If this problem occurred to you suddenly, it may be that it was corrupted while generating the apk.如果您突然出现此问题,可能是在生成 apk 时它已损坏。 This rarely happens这很少发生

Solution: rebuild tasks解决方案:重建任务

you can see it in this image你可以在这张图片中看到它

将存储库更新到最新版本为我解决了这个问题。

implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'

在我的情况下,我只是将我的项目级别构建 Gradle 和其他依赖项更改为最新版本,并将应用程序级别构建 gradle 中的 Google Maps 依赖项更改为 10.0.0。

您是否尝试在您的依赖项中添加此内容:

implementation 'com.google.android.gms:play-services-basement:15.0.0'

Just Build → Clean Project 对我有用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决未解析的依赖 ':app@debug/compileClasspath': 无法解析 com.google.android.gms:play-services-base:[15.0.0, 16.0.0) - How to solve the unresolve dependency ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-base:[15.0.0, 16.0.0) 错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析 com.google.android.gms:play-services-base - ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-base 无法解析:com.google.android.gms:play-services-basement:12.0.1 - Failed to resolve: com.google.android.gms:play-services-basement:12.0.1 “找不到与com.google.android.gms:play-services-basement:[15.0.1,16.0.0)匹配的任何版本” - “Could not find any version that matches com.google.android.gms:play-services-basement:[15.0.1,16.0.0)” 无法解决依赖 com.google.android.gms:play-services-location:16.0.0 - could not to resolve the dependency com.google.android.gms:play-services-location:16.0.0 找不到与com.google.android.gms:play-services:[15.0.0,16.0.0)匹配的任何版本 - Could not find any version that matches com.google.android.gms:play-services:[15.0.0, 16.0.0) 无法解析 com.google.android.gms:play-services-base:[15.0.1,16.0.0) - Could not resolve com.google.android.gms:play-services-base:[15.0.1,16.0.0) 无法解析':app @ debug / compileClasspath'的依赖项:无法解析com.android.volley:volley:1.1.1 - Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.volley:volley:1.1.1 无法解析 ':app@debug/compileClasspath' 的依赖:无法解析 com.android.databinding:library:3.2.1 - Unable to resolve dependency for ':app@debug/compileClasspath':Could not resolve com.android.databinding:library:3.2.1 无法解析':app @ debug / compileClasspath'的依赖项:gradle同步时无法解决com.google.android.things:androidthings:1.0错误 - Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.things:androidthings:1.0 error while gradle sync
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM