//implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
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?

asked Nov 23 '18 at 14:24
Google

29811 gold badge33 silver badges44 bronze badges
 

4 Answers

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-jdkkotlin-stdlib-jre is now no longer maintained as a separate dependency.

Both IntelliJ and Android Studio currently generate new projects using kotlin-stdlib-jre7this 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.

answered Nov 23 '18 at 14:45
Zoe the transgirl

16.3k1212 gold badges6969 silver badges9999 bronze badges
 
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'

answered Apr 4 at 7:22
Soumen Das

55555 silver badges1010 bronze badges
 
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'
barbsan

3,04788 gold badges1515 silver badges2626 bronze badges
answered Jul 11 at 7:04
 

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.

 
Looking for a job?

  • React Developer [REMOTE]
    ClevertechNo office location
    REMOTE

    reactredux

     
  • Product Manager at Forward Thinking Remote Company
    SuperformulaNo office location
    $140K - $175KREMOTE

    node.jsflutter

     
  • Senior Android Software Engineer
    LalamoveKowloon, Hong Kong
    $45K - $90KRELOCATIONVISA SPONSORSHIP

    androidjava

     
  • Senior Software Developer for macOS
    ChengbaoHong Kong
    REMOTE

    swiftobjective-c

     
 

How to resolve error “Failed to resolve: org.jetbrains.kotlin:kotlin-stdlib-jre7…” when building in Android Studio Ask Question的更多相关文章

  1. Error:Failed to resolve: com.afollestad:material-dialogs:

    http://www.chenruixuan.com/archives/1068.html 背景: 同事把Android项目直接考给了我...我在Android Studio上运行,然后提示: Err ...

  2. Android Error:Failed to resolve: com.afollestad:material-dialogs:

    背景: 同事把Android项目直接考给了我...我在Android Studio上运行,然后提示: Error:Failed to resolve: com.afollestad:material- ...

  3. Error:Failed to resolve: com.android.support:support-annotations:26.0.2

    异常信息记录: Error:Failed to resolve: com.android.support:support-annotations:26.0.2 <a href="ins ...

  4. (转)Android Studio Error:Failed to resolve: com.android.support:appcompat-v7:25.1.0解决方案

    今天不知道为什么导入eclipse项目后就出现了错误,没导入之前是正常使用AS的 Error:(26, 13) Failed to resolve: com.android.support:appco ...

  5. Error:Failed to resolve: com.android.support:recyclerview-v7:28.0.0解决方法

    在使用Android Studio的过程中需要添加依赖recyclerview,出现报错: Unable to resolve dependency for ':app@debug/compileCl ...

  6. AndroidStudio — Error:Failed to resolve: junit:junit:4.12错误解决

    原博客:http://blog.csdn.net/u013443865/article/details/50243193 最近使用AndroidStudio出现以下问题: 解决:打开app下的buil ...

  7. Error:Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2

    可以换个maven库: allprojects { repositories { jcenter() //maven { url "https://jitpack.io" } ma ...

  8. Error:Failed to resolve: com.android.support:appcompat-v7

    repositories { maven { url "https://maven.google.com" } } implementation 'com.android.supp ...

  9. Error:Failed to resolve: :Base:

    这个问题是变通了一下,原来是: //implementation(name: "Base", ext: "aar") 修改成: implementation f ...

随机推荐

  1. 【SQL Server复制】数据库复制:修改表结构、新增表、新增存储过程 会被复制到订阅服务器?

    转自:https://www.cnblogs.com/happyday56/p/3849018.html 关键字:sql server复制 [SQL Server高可用性]数据库复制:修改表结构.新增 ...

  2. hdu-1045.fire net(缩点 + 二分匹配)

    Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  3. Dubbo源码学习总结系列三 dubbo-cluster集群模块

    Dubbo集群模块的目的是将集群Invokers构造一个透明的Invoker对象,其中包含了容错机制.负载均衡.目录服务(服务地址集合).路由机制等,为RPC层提供高可用.高并发.自动发现.可治理的S ...

  4. Python中queue消息队列模块

    from queue import Queue from queue import PriorityQueue print("Queue类实现了一个基本的先进先出(FIFO)容器,使用put ...

  5. 使用Jmeter聚合报告生成对比图表

    背景 最近在帮别的项目组执行性能测试,使用的工具是Jmeter.接口录制和参数化前一个人已经做好了,我主要的工作就是执行脚本,撰写测试报告.事情并不复杂,可做起来却极为耗时. 首先,由于有6组账号,分 ...

  6. 关于windows服务器配置

    #我是用的window service2008系统,在配置服务器时由于是用php进行搭建 #首先我安装好phpstudy,通过服务器ip访问,显示了个helloworld,我查看了phpstudy里的 ...

  7. 初学Java 二维数组找出最近的两个点

    import java.util.Scanner; public class FindNearestPoints { public static void main(String[] args) { ...

  8. [SDOI2015]寻宝游戏(LCA,set)

    [SDOI2015]寻宝游戏 题目描述 小B最近正在玩一个寻宝游戏,这个游戏的地图中有N个村庄和N-1条道路,并且任何两个村庄之间有且仅有一条路径可达.游戏开始时,玩家可以任意选择一个村庄,瞬间转移到 ...

  9. spring requestbody json

    1  @requestbody string param 前台将jsonobject序列化成字符串 后台解析成JsonObject 2 @requestbody map<string,objec ...

  10. ps:图像尺寸

    在课程#01中我们知道了显示器上的图像是由许多点构成的,这些点称为像素,意思就是“构成图像的元素”.但是要明白一点:像素作为图像的一种尺寸,只存在于电脑中,如同RGB色彩模式一样只存在于电脑中.像素是 ...