Roc Boronat
Roc Boronat

Reputation: 12141

"Extension with name 'android' does not exist" error when adding Kotlin to Android project

When I try to add Kotlin to our Android project using the official Kotlin tutorial, Gradle fails launching the error Extension with name 'android' does not exist.

Upvotes: 43

Views: 25031

Answers (4)

Halil Ozel
Halil Ozel

Reputation: 3312

enter image description here

New use in 2022:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

Upvotes: 0

Abd Nezar
Abd Nezar

Reputation: 411

with new versions use

plugins {
  id 'com.android.application'
  id 'kotlin-android'
}

Upvotes: 6

Roc Boronat
Roc Boronat

Reputation: 12141

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'

Upvotes: 104

Mani
Mani

Reputation: 969

This is the correct order for above extension issue.

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

Upvotes: 17

Related Questions