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

Tapas Mukherjee picture Tapas Mukherjee · Oct 23, 2019 · Viewed 15.1k times · Source

I am getting the following error suddenly while building Ionic 3 app for Android.

Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25

We have one solution from Android Studio here but after I did change in my build.gradle with the following code I am still getting the error.

buildscript {
    repositories {
        ...
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
}

allprojects {
    repositories {
        ...
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }
}

My build.gradle file looks like this after I updated my Cordova and added the above solution.

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }

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

        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    }

    //This replaces project.properties w.r.t. build settings
    project.ext {
      defaultBuildToolsVersion="28.0.3" //String
      defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
      defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
      defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
    }
}

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

Still the same error.

Answer

Mister Smith picture Mister Smith · Oct 24, 2019

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.