Error: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25 in Ionic 3

The problem lies in the cordova-support-google-services plugin for Cordova.

This plugin's build.gradle looks like this as of today (October 24th, 2019):

dependencies {
    classpath 'com.android.tools.build:gradle:+'
    classpath 'com.google.gms:google-services:4.2.0'
}

More exactly the problem lies in this dependency:

classpath 'com.android.tools.build:gradle:+'

That is an extremely brittle way of specifying dependencies. The '+' sign here means "fetch the most recent version available in the repo". If a newer version is published in the repo, and it breaks the build, then everyone with this plugin has their projects broken. This happened today. The broken version that is being fetched is com.android.tools.build:gradle:4.0.0. It requires some Kotlin stuff.

That is why you need to ALWAYS freeze dependencies to reliably build your project. Never trust the newer stuff. This dependency compiles fine just as it did yesterday:

classpath 'com.android.tools.build:gradle:3.5.1'

For those using Cordova or Ionic, you can make a quick fix to be able to build the project by freezing the dependency in the file:

<projectroot>/platforms/android/cordova-support-google-services/<project>-build.gradle

This is not a definitive solution though. If you reinstall the android platform via Cordova the error will show up again. The project maintainer should either freeze the dependency or fix it to support gradle 4.0.0. In the meantime just use a fixed fork of this plugin.


EDIT 10/28/19:

cordova-support-google-services was updated today to version 1.3.2 which changes the classpath from classpath 'com.android.tools.build:gradle:+'

to

classpath 'com.android.tools.build:gradle:3.+'

which seems to fix the kotlin error

Original Answer

I got mine to build successfully by doing the following:

I edited platforms->android->cordova-support-google-services->myAppName-build.gradle

and changed

maventCentral()

to

    maven { url "https://maven.google.com" }
    maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }

That solved the kotlin error then I was getting a different error that I resolved by changing

classpath 'com.google.gms:google-services:4.2.0'

to

classpath 'com.google.gms:google-services:4.1.0'

It then built successfully.


Here is the solution.

The problem was exactly the maven repository (here), but the issue was with the build.gradle from the cordova-support-google-services plugin, so I added the required line and everything is ok now, I've already created a pull request to the original repo (here). But in the meantime you can do what I did, just replace in the package.json the current versión with my repo:

Before:

...
"cordova-support-google-services": "^1.3.1",
...

After:

...
"cordova-support-google-services": "https://github.com/LuisEGR/cordova-support-google-services.git",
...

after that you will have to:

  • Remove folders platforms and plugins
  • run npm install

This is a temporal solution while the pull request to the main repo gets accepted and the npm package updated

and that's it, now you can build your project again.


I'm using Ionic 4, and some plugins require cordova-support-google-services, in case you don't have it in your package.json the error could be with another plugin, if so please add the package.json so we can find out which one is the problem.


UPDATE 24/OCT:

I've changed the solution in my repo as many of you suggested, now the solution consinst just in fixing the dependency: from: com.android.tools.build:gradle:+ to classpath com.android.tools.build:gradle:3.+, this is already in my repo if you want to see what's changed