简体   繁体   English

如何在Android Studio中配置Kotlin版本?

[英]How to configure Kotlin version in Android Studio?

I have configured the Kotlin version in project's build.gradle. 我在项目的build.gradle中配置了Kotlin版本。 But in Other Settings->Kotlin Compiler , it shows an older version. 但在其他设置 - > Kotlin编译器中,它显示的是旧版本。 How to fix that? 如何解决?

project的build.gradle

Android Studio的设置

It is not showing you outdated version. 它没有显示你过时的版本。 Let's say your plugin version is '1.1.3', so your compiler version is '1.1' not '1.1.3'. 假设你的插件版本是'1.1.3',所以你的编译器版本是'1.1'而不是'1.1.3'。 Now, if you will update your kotlin by going in 现在,如果您将通过进入更新您的kotlin

Tools > Kotlin > Configure Kotlin Updates 工具> Kotlin>配置Kotlin更新

to early access version '1.2' as shown in screenshot below, you will be able to see '1.2' in you 'Kotlin compiler' settings. 如早期访问版本“1.2”,如下面的屏幕截图所示,您将能够在“Kotlin编译器”设置中看到“1.2”。

在此输入图像描述

In your Android studio, Go to Tools -> Kotlin -> Configure Kotlin Updates. 在Android工作室中,转到工具 - > Kotlin - >配置Kotlin更新。

For more details you can check https://segunfamisa.com/posts/setting-up-android-studio-for-kotlin-development 有关详细信息,请查看https://segunfamisa.com/posts/setting-up-android-studio-for-kotlin-development

Open you project gradle and add this line 打开项目gradle并添加此行

 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.3-2"

After configuration project Gradle you need to add app Gradle. 配置项目Gradle之后,您需要添加应用程序Gradle。 add kotlin plugin after android plugin like this 像这样的Android插件之后添加kotlin插件

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

And the Last step add dependencies 最后一步添加依赖项

   compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.3-2"

And Click SYNC Project. 然后单击SYNC Project。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM