Android gradle Failed to resolve: play-services-basement

强颜欢笑 提交于 2019-11-27 01:44:21

问题


suddenly gradle is unable to build the same code that was working moments ago ! my project depends on google play service dependencies

it says :

Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1). Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar

I think the aar file was removed from google by mistake

Does anyone have any idea, what is going on?


回答1:


Add google() repository in your build.gradle. And check that google() is before jcenter().




回答2:


The problem seems to be with jcenter. I have spent hours together with this problem and your problem seems to be similar to mine and I think the following solution should work.

For some reason and for many libraries in jcenter, the pom files of many libraries are kept in place but corresponding aar files have been removed. This is also the case with play-services-basement library. Check the following here for reference ( pom file of play-services-basement is available at jcentre here but aar file is not available at jcentre here):

Solution : In your project level gradle file , change the following block of code

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

to

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

why this works ?

In our first code block, when gradle tries to resolve a dependency in the repository(in my case,it was google-services-basement in jcentre repository), it ddi not get resolved as corresponding aar files has been removed. As a result , build fails with something like :

 Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1).

In our second code block, google repository has been referenced before jcenter repository. When gradle build starts, it looks first in the libraries listed first in repositories{... for resolving any library that is used in the project. Now, when gradle tries to resolve play-services-basement in jcenter, it is successful in resolving dependency as corresponding aar file has been made available by google repository(the same aar file of latest version is not available in jcenter repository) which has been referenced before jcenter repository is assessed. Do check and let me know if that works.




回答3:


IN Worked

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

}


来源:https://stackoverflow.com/questions/52948514/android-gradle-failed-to-resolve-play-services-basement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!