[android] Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7

I installed the Kotlin plugin into my app (v. v1.1.1-release-Studio2.2-1) and then selected "Configure Kotlin in Project" I selected compiler and runtime version of 1.0.7. Kotlin updated my Gradle files. Now when I try to build in I get:

Error: A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugApkCopy'. Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7. Required by:

MyApplication:app:unspecified

I'm not sure what I'm missing here.

This question is related to android kotlin android-gradle-plugin

The answer is


Reload sdk maybe the problem is solved


Simple Steps:

  1. Click File > Project Structure

  2. Click Dependencies > Find and Click org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.21 (or whatever your current version is)

  3. Under Details > update section, click [update variable][update dependencies]

  4. Click Ok

Best Regards


After fixing the build.gradle version, It started working 4.0.0 to 3.5.0


If you are using Android Studio 3.2 & above,then issue will be solved by adding google() & jcenter() to build.gradle of the project:

repositories {
        google()
        jcenter()
}

build.gradle (Project)

buildScript {
    ...
    dependencies {
        ...
        classpath 'com.android.tools.build:gradle:4.0.0-rc01'
    }
} 

gradle/wrapper/gradle-wrapper.properties

...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Some libraries require the updated gradle. Such as:

androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"

GL


Starting with Kotlin 1.1.2, the dependencies with group org.jetbrains.kotlin are by default resolved with the version taken from the applied plugin. You can provide the version manually using the full dependency notation like:

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

If you're targeting JDK 7 or JDK 8, you can use extended versions of the Kotlin standard library which contain additional extension functions for APIs added in new JDK versions. Instead of kotlin-stdlib, use one of the following dependencies:

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

The split of kotlin-stdlib into kotlin-stdlib-jre7 and kotlin-stdlib-jre8 was only introduced with Kotlin 1.1, that's why the dependency cannot be resolved, the package version simply does not exist.

It looks like the update to your project files failed at some point and set the Kotlin version to 1.0.7. If this is a new project and there's nothing holding you back from using 1.1.1, I'd switch to that. Your problem should be gone after doing this.


buildscript {
    **ext.kotlin_version = '1.1.1'**  //Add this line
    repositories {
        **jcenter()**                 //Add this line
        google()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.android.tools.build:gradle:3.1.0'

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

allprojects {
    repositories {
        **jcenter()**                 //Add this line
        google()
        maven { url "https://jitpack.io" }
    }
}

In case a (transitive) dependency still uses the jre variant of the Kotlin library, you can force the use of the jdk variant with the help of a resolution strategy:

configurations.all {
    resolutionStrategy {
        eachDependency { DependencyResolveDetails details ->
            details.requested.with {
                if (group == "org.jetbrains.kotlin" && name.startsWith("kotlin-stdlib-jre")) {
                    details.useTarget(group: group, name: name.replace("jre", "jdk"), version: version)
                    details.because("Force use of 'kotlin-stdlib-jdk' in favor of deprecated 'kotlin-stdlib-jre'.")
                }
            }
        }
    }
}

A new solution if you use Android Studio 3.2, I solved this issue by added mavenCentral() to build.gradle of the project:

buildscript {
    ext.kotlin_version = '1.3.0'
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    }
}

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

You should add the line as this order, the credited is for this answer


This is what worked for me: Using Gradle 4.8.1

buildscript {
    ext.kotlin_version = '1.1.1' 
repositories {
    jcenter()
    google()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.0'}
}
allprojects {
    repositories {
        mavenLocal()
        jcenter()
        google()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    maven {
            url 'https://dl.bintray.com/kotlin/kotlin-dev/'
    }
  }
}   

  1. Please check current version of your Kotlin in below path,

    C:\Program Files\Android\Android Studio\gradle\m2repository\org\jetbrains\kotlin\kotlin-stdlib\1.0.5

change to that version (1.0.5) in project level gradle file.

You can see in your above path does not mentioned any Java - jre version, so remove in your app level gradle file as below,

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

I have solved this issue using deselection of the Offline work option in Settings

enter image description here


In Project level build.gradle use only this version

ext.kotlin_version = '1.3.31'

Remove other versions

This will only work with the latest version of android studio 3.4

UPDATE: Try to use the latest version of kotlin with latest Android studio to avoid an error.


In "build.gradle" file, change current Kotlin version that line and press synk:

ext.kotlin_version = '1.1.1'

/// That will look like:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.1.1'
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

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

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to kotlin

No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator How to allow all Network connection types HTTP and HTTPS in Android (9) Pie? Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Default interface methods are only supported starting with Android N Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 startForeground fail after upgrade to Android 8.1 How to get current local date and time in Kotlin How to add an item to an ArrayList in Kotlin? HTTP Request in Kotlin

Examples related to android-gradle-plugin

WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Android Material and appcompat Manifest merger failed Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries Invoke-customs are only supported starting with android 0 --min-api 26 error: resource android:attr/fontVariationSettings not found Exception : AAPT2 error: check logs for details Could not resolve com.android.support:appcompat-v7:26.1.0 in Android Studio new project Failed to resolve: com.android.support:appcompat-v7:27.+ (Dependency Error)