When I try to add Kotlin to our Android project using the official Kotlin tutorial (https://kotlinlang.org/docs/tutorials/kotlin-android.html), Gradle fails launching the error Extension with name 'android' does not exist
.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Android Studio modifies your build.gradle
adding apply plugin: 'kotlin-android'
above apply plugin: 'com.android.application'
. Just move the Kotlin line below the Android one and Gradle will run smoothly. It should look like this example:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
回答2:
This is the correct order for above extension issue.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'