//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. PHP 登陆失效之后,重新登陆,跳转到失效前界面

    登陆失效之后,需要重新进行登陆,登陆之后,进入到默认首页,如果需要继续之前的进行操作,必须重新点击菜单进行跳转,体验不太好 登陆的时候,将之前的url,拼接到登陆界面的url上作为一个redirect ...

  2. Java数据结构之链表(Linked List)

    1.链表(Linked List)介绍 链表是有序的列表,但是它在内存存储结构如下: 2.特点: 链表是以节点的方式来存储,是链式存储 每个节点包含 data 域, next 域:指向下一个节点. 链 ...

  3. POJ-2456.Aggressivecows.(二分求解最大化最小值)

    本题大意:在坐标轴上有n个点,现在打算在这n个点上建立c个牛棚,由于牛对厂主的分配方式表示很不满意,它很暴躁,所以它会攻击离它很近的牛来获得快感,这件事让厂主大大知道了,他怎么可能容忍?所以他决定有策 ...

  4. React.memo

    介绍React.memo之前,先了解一下React.Component和React.PureComponent. React.Component React.Component是基于ES6 class ...

  5. 【Vue】通过自定义指令回顾 v-内置指令

    Vue.js 的各种指令(Directives)更加方便我们去数据驱动 DOM,例如 v-bind.v-on.v-model.v-if.v-for.v-once 等内置指令,这些指令的职责就是当表达式 ...

  6. Arcmap10.7连接oracle,但不装oracle客户端的配置

    环境:arcgis 10.7,oracle服务端12cR1.理论上其他版本方法一样 使用情况:一般开发人员不安装oracle服务端,甚至oracle客户端也不装,此时要用arcmap连oracle需要 ...

  7. linux NFS 客户端的安装

    1. 安装 showmount [root@allentuns ~]# yum -y install showmount 2. 查看服务器共享 [root@allentuns ~]# showmoun ...

  8. 创建entityManager

    1 需要persistence.xml 完全通过属性配置没成功 <persistence xmlns="http://java.sun.com/xml/ns/persistence&q ...

  9. HTML5 音频播放

    代码实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  10. bzoj2402 陶陶的难题II 分数规划+树剖+线段树维护凸壳+二分

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2402 题解 看上去很像分数规划的模型.于是就二分吧.令 \[ \begin{align*}\f ...