//implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

 

​Ask Question​

Asked 10 months ago

Active ​​2 months ago​

Viewed 19k times


53

12

I've created a new project by checking the "include kotlin" box in Android Studio 3 and out of the box I get an error while compiling

"Failed to resolve: org.jetbrains.kotlin:kotlin-stdlib-jre7..."

I have made sure all plugins are up to date and that the Android SDK is properly installed.

Would anyone know how to solve for this error?

​kotlin​

​share​​​​improve this question​

​edited Apr 14 at 15:00​

​Android_Newbie​

666 bronze badges

asked Nov 23 '18 at 14:24

​Google​

29811 gold badge33 silver badges44 bronze badges

 

 

add a comment


4 Answers

​active​​​​oldest​​​​votes​


117

 

​kotlin-stdlib-jre[7/8]​​​ was deprecated a while ago, and has since been removed. The deprecation note was kept until ​​1.2.71​​​, which was the last version to release those artifacts. The official deprecation notice can be found ​​here​​. Using any of the deprecated versions (before it was removed) should also produce a warning in (at least) Android Studio and IntelliJ.

Use ​​kotlin-stdlib-jdk7​​​ instead. It's the same dependency as ​​kotlin-stdlib-jre7​​​ (except newer), but it was re-named to ​​kotlin-stdlib-jdk​​​. ​​kotlin-stdlib-jre​​ is now no longer maintained as a separate dependency.

Both IntelliJ and Android Studio currently generate new projects using ​​kotlin-stdlib-jre7​​; this likely is a bug. They have probably not updated the project generators. Therefore, you have to manually replace the dependencies with working ones until they fix this. This is dependent on the Kotlin plugin. Update it if you haven't. I haven't checked whether it's been patched or not - if it has, that only fixes the creation of new projects. For updating from older versions, the rest of the answer still applies

You naturally have to do this if you're on 1.2.71 or lower, and you're upgrading to 1.3.0 or higher.

These are the new valid dependencies as of Kotlin 1.3.0:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

Where ​​$kotlinVersion​​​ is either a variable containing the version, or a hard-coded version (i.e. ​​1.3.0​​)


Alternatively, you can use ​​the "plain" stdlib​​​ (​​kotlin-stdlib​​​) instead of the JDK-specific versions. But you have to change your dependency either way, so I recommend you go with ​​kotlin-stdlib-jdk7​​​, or if you plan on using Java 8, ​​kotlin-stdlib-jdk8​

The newest versions of the dependencies can also be found ​​here​​. jdk7, jdk8, and the version-unspecific stdlib all follow the same versions (as per this edit - this could change in the future, but there'll likely be notices before that change happens), so whether you check jdk8, jdk7 or the regular one, all the versions should be universally available across the stdlib artifacts.

Note for other build systems

The same actual solution applies to other build systems as well, but the code is different. As there are a lot of build systems, I'm not going to include all of them, but the point is changing the artifact from ​​kotlin-stdlib-jre[num]​​​ to ​​kotlin-stdlib-jdk[num]​​​ (without brackets of course). Or, as mentioned earlier, ​​kotlin-stdlib​​.

Independently of the build system, this bases itself on access to Maven Central and similar repositories. If your build system doesn't support this, and/or breaks with Maven-style conventions and repositories, you'll have to find what works for your build system.

TL;DR:

Use ​​org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version​​​ or ​​org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version​​ (depending on which version you originally used) instead.

​share​​​​improve this answer​

​edited May 9 at 15:01​

 

 

answered Nov 23 '18 at 14:45

​Zoe the transgirl​

16.3k1212 gold badges6969 silver badges9999 bronze badges

 

 

add a comment


16

Remove this line from the build.gradle:

implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

Add this line in the build.gradle:

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

Update the version build.gradle in project level: kotlin version='1.3.0'

​share​​​​improve this answer​

​edited Apr 4 at 7:45​

 

 

answered Apr 4 at 7:22

​Soumen Das​

55555 silver badges1010 bronze badges

 

add a comment


0

In build.gradle (Module:app) replace

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

with

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

and in build.gradle (Module:project) change version to

ext.kotlin_version = '1.3.0'

​share​​​​improve this answer​

​edited Jul 11 at 7:24​

​barbsan​

3,04788 gold badges1515 silver badges2626 bronze badges

answered Jul 11 at 7:04

​NIRMAL KUMAR​

11

 

 

add a comment


0

In general cases, check for available artifacts at

​https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jdk7​​​​https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jre7​​​​https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jdk8​​​​https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jre8​

​share​​​​improve this answer​

answered Aug 6 at 7:18

​Nezneika​

13911 silver badge77 bronze badges

 

add a comment

protected by ​​Zoe the transgirl​​ Jul 18 at 18:27

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 ​​reputation​​​ on this site (the ​​association bonus does not count​​​). 

Would you like to answer one of these ​​​unanswered questions​​ instead?

Not the answer you're looking for? Browse other questions tagged ​​kotlin​​​ or ​​ask your own question​​.

Blog

Featured on Meta

 

Looking for a job?​

  • React Developer [REMOTE]ClevertechNo office locationREMOTE ​​reactredux​​​  
  • Product Manager at Forward Thinking Remote CompanySuperformulaNo office location$140K - $175KREMOTE ​​node.jsflutter​​​  
  • Senior Android Software EngineerLalamoveKowloon, Hong Kong$45K - $90KRELOCATIONVISA SPONSORSHIP ​​androidjava​​​  
  • Senior Software Developer for macOSChengbaoHong KongREMOTE ​​swiftobjective-c​​​  

Linked

9

​cannot start android on intellij​

0

​Android resource compilation failed after updating android studio​

Related

146

​Error: Execution failed for task ':app:clean'. Unable to delete file​

5

​Kotlin plugin error in android studio​

100

​Unresolved reference: kotlinx​

78

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

151

​Outdated Kotlin Runtime warning in Android Studio​

7

​Why Kotlin plugin adds kotlin-stdlib-jre7 (not kotlin-stdlib) reference for Android project​

0

​Error:Unable to resolve version for dependency 'org.jetbrains.kotlin:kotlin-stdlib-jre7:jar'​

43

​kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead​

1

​Android Studio - Could not find org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2​

9

​cannot start android on intellij​

​Hot Network Questions​

​more hot questions​