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

Hello, I am getting the following error when compiling for Android 6.3.0:

* What went wrong:
A problem occurred configuring root project 'android'.
> 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

My Ionic info:

cli packages: (C:\Users\Dialogo\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.3
    ionic (Ionic CLI) : 3.20.1

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.10
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.11.1
    npm  : 5.6.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

I know a possible fix is moving jcenter() after the repositories{...} in the gradle.build but I don’t like this workarround since it has to be done every time you build a new project.

Is there anything that can fix this permanently?

Thanks.

1 Like

I’m facing the same problem and found no solution yet. Here is the same question for reference: https://stackoverflow.com/questions/52953962/how-to-extend-cordova-build-gradle-to-change-repositories

1 Like

After alot of research, I found out in a comment (not even an answer) from stackoverflow the solution to this:

  1. Remove platforms , plugins and node_modules folder (lets do everything from scrach so it’s cleaner).
  2. Do npm install
  3. Do ionic cordova platform add android
  4. Do cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=15.0.0 --fetch
  5. Now finally you can do ionic cordova run android or ionic cordova build android
10 Likes

For others having this issue, it originates from certain files not being found on jcenter().

HERE’S HOW TO FIX IT

You need to edit your build.gradle file found under platforms/android

Under buildscript and allprojects, move jcenter() to the bottom of the list as follows:

repositories {
    maven {
        url "https://maven.google.com"
    }
	maven { url 'https://plugins.gradle.org/m2/' }
    jcenter()
}
2 Likes

The problem is that it tries to find Play services 15.0.1 in a repository which doesn’t exist like the error indicates. With the plugin I put in the solution you can specify which play services version you want and it’ll somehow download and use that play services version.

Your way (which is the one I knew as I say in the first post) is a dirty workaround in my opinion, since you have to do that manually every time you add an Android platform. With the plugin from the solution you just specify the version for play services (I chose 15.0.0 which is the best and one of latest as I read somewhere) and forget about this problem forever.

Also I read it’s handy to solve problems if you have some plugins related to Google installed since some might have integrated different play services versions and they can cause incompatibilities among each other. With this you force them all to use the same version so no more compatibility issues.

worked for me
thanks

I deleted the platforms folder, then reinstalled the android platform, and now jcenter() is at the bottom.

…and then it wasn’t! (had to reinstall the platform a few times, sometimes it was in the right place, sometimes not!)

(I personally don’t like the idea of hardcoding the path?)