11

I'm trying to build/run an ionic project but from today this error comes up and I could not find any answer. Please, help me.

Error: Could not find any matches for com.android.tools.build:gradle:+ as no versions of com.android.tools.build:gradle are available.

  • Ionic Version: 4.5.0
  • Cordova: 6.5.0
  • NPM: 6.4.1
  • Gradle: Gradle 4.10.2

  • Kotlin DSL: 1.0-rc-6

  • Kotlin: 1.2.61
  • Groovy: 2.4.15
  • Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
  • JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
  • OS: Windows 7 6.1 amd64
shizhen
  • 12,251
  • 9
  • 52
  • 88
Enzo Gerola
  • 141
  • 1
  • 6

6 Answers6

6

On my specific case the problem was with fcm plugin, this was what I did:

  • In platforms/android/build.gradle check buildscript gradle classpath version, my case was 2.2.3 (com.android.tools.build:gradle:2.2.3)

  • Then, in platforms/android/cordova-plugin-fcm/XXXX-FCMPlugin.gradle change classpath 'com.android.tools.build:gradle:+' to the same version found above: classpath 'com.android.tools.build:gradle:2.2.3'

That's it, fixed for me.

Niroog
  • 61
  • 2
4

On my case i had this issue with the phonegap push plugin. I followed @Niroog solution and and was able to solve it. Here is what i did:

  • In platforms/android/build.gradle my gradle classpath version was 2.2.3
  • I changed "classpath 'com.android.tools.build:gradle:+' in "platform/android/phonegap-plugin-push/****-push.gradle" to "com.android.tools.build:gradle:2.2.3'" under dependencies

I saved and ran cmd "ionic cordova build android -prod" in terminal and it built successful.

3

Facing the same issue since earlier today. The solutions above didn't work for me. Came across another thread here...
https://forums.adobe.com/message/10804391#10804391

This one didnt work as well.Maybe I am doing something wrong..

----------EDIT-----------

Here is what worked for me

1) update build.gradle

buildscript {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}..... 

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

2) update cordova-plugin-fcm/xxxxxx-FCMPlugin.gradle

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

Inspired from: https://developer.android.com/studio/releases/gradle-plugin

Arjun Shankar
  • 231
  • 2
  • 3
2

My issue was with the intercom-cordova-plugin which requires version 2.2.3 currently.

I just started getting this error today as well. Not 100% sure why, but maybe check your platforms/android/ directory for any plugins *.gradle files that are trying to include the version of gradle that's not found.

Updating cordova-plugin-intercom/mtg-intercom.gradle to use 3.1.0 got it working again. I suspect something went wrong with a remote maven/gradle repository, and we're seeing some downstream effects.

Lincoln
  • 3,151
  • 17
  • 22
1

Thanks, @Niroog. Your solution works and I voted up for your answer. But the solution works only for Cordova android version 6.3.0 and greater. In my case, I had two projects:

  • Project 1: Cordova android version 6.3.0,
  • Project 2: Cordova android version 6.2.3

For Project 1, the solution given by @Niroog above works fine.

But if someone using version 6.2.3, Here is the solution:-

Step 1:

ionic cordova platform rm android
ionic cordova platform add android@6.3.0 // or greater
ionic cordova prepare android

Step 2: Follow @Niroog's solution above. And build now

ionic cordova build android

If you still face an error follow step 3. Because in my case after upgrading to 6.3.0, "cordova-plugin-push" folder was generated automatically. So I have to repeat the same solution for push.gradle file too.

Step 3:

In platforms/android/cordova-plugin-push/XXXX-push.gradle change classpath 'com.android.tools.build:gradle:+' to the same version found above: classpath 'com.android.tools.build:gradle:2.2.3'

Then ionic cordova build android

shizhen
  • 12,251
  • 9
  • 52
  • 88
Durga Sriram
  • 406
  • 3
  • 16
1
subprojects {
    if (project.name.startsWith('react-native-')){
        buildscript {
            repositories {
                jcenter()
                maven { url "https://dl.bintray.com/android/android-tools/"  }
            }
        }
    }
}

Try above work around.

shizhen
  • 12,251
  • 9
  • 52
  • 88