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

190,657

Solution 1

replace

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
                                                    ^
                                                    |
                                      JRE = Java Runtime Environment

with

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
                                                    ^
                                                    |
                                       JDK = Java Development Kit

Since the version with jre is absolute , just replace and sync the project

Official Documentation here Thanks for the link @ ROMANARMY

Solution 2

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.

Solution 3

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.

Solution 4

If you hereafter removing Jcenter from Gradle then add this to your gradle

repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }



allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}

So main point is that, add mavenCentral() and maven { url "https://jitpack.io" } in gradle

Solution 5

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
    }
}
Share:
190,657
Mike6679
Author by

Mike6679

Updated on July 08, 2022

Comments

  • Mike6679
    Mike6679 almost 2 years

    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.

  • Don Hatch
    Don Hatch over 6 years
    An answer that specifies a magic version to use, without explanation, is not all that helpful and becomes even less helpful over time. Are you suggesting upgrading from a lower version? Or downgrading from a higher version because the higher version has a bug?
  • Don Hatch
    Don Hatch over 6 years
    Thank you for explaining. Several answers say use 1.1.1 without explanation, which will make the answers rapidly become useless in the future.
  • Patel Pinkal
    Patel Pinkal over 6 years
    @DonHatch this answer was given in March for android studio 2.2 which was getting error mention above in the question. It is not for android studio 3.0 or above.
  • Nemo
    Nemo about 6 years
    You could elaborate on how this improves Mihail Salari's answer, on which it seems to be based.
  • Roman
    Roman over 5 years
    Some helpful information in the docs about jdk and jre.
  • Lou Morda
    Lou Morda over 5 years
    @0xalihn answer below has a correct solution without magic version number
  • Farid
    Farid over 5 years
    I believe one day Android team will make things a little easier not much just a little or at least they will write major changes in changelog with bold instead of burying it deep into the website to be mined out :))
  • James Wang
    James Wang over 5 years
    It took me a full minute of staring to see the difference between jre and jdk—I must be getting old.
  • Arbaz.in
    Arbaz.in about 5 years
    @PatelPinkal can you update your answer for latest android studio version.
  • Patel Pinkal
    Patel Pinkal about 5 years
    @Arbaz.in try to install and use a new version of kotlin. May its help you. Also, note that your studio should be the latest version if you are using latest kotlin version.
  • Arbaz.in
    Arbaz.in about 5 years
    @PatelPinkal Sure ill do same
  • Patel Pinkal
    Patel Pinkal about 5 years
    Ok, If it's working then edit this post or provide your answer here. So, others can have solutions.
  • Arbaz.in
    Arbaz.in about 5 years
    i updated answer as per latest version of Android studio
  • Patel Pinkal
    Patel Pinkal about 5 years
    @Arbaz.in I can't see any update in answer. Please post your answer in a comment
  • Hamed Zakery Miab
    Hamed Zakery Miab over 2 years
    which file should i search for this?
  • Alexandre G
    Alexandre G about 2 years
    Thanks. Only needed mavenCentral() for me (to replace jcenter())