Error setting up a new Kotlin Project in Android Studio


#1

Hello,

in order to get in touch with Kotlin and Android I tried setting up a new project using Android Studio.
(Fresh AS Installation with no additional settings)

Therefore I followed the official instruction provided here


and set everything up accordingly.
(Btw, it appears to me that in this instruction it’s assumed Kotlin was shipped with Android Studio by default - it wasn’t for me. I had to apply the plugin manually.)

Eventually I had my MainActivity.java set up and converted it to Kotlin.
Then I “configured my Project for Kotlin” using the appearing Notification.

Shortly after, “Plugin Errors” kept showing up, stating the following:

Plugin Error: Kotlin threw an uncaught NoClassDefFoundError. Disable Plugin
NoClassDefFoundError: com/android/tools/idea/rendering/LocalResourceRepository

I tried re-enabling the Plugin several times. Also changing up the order of the dependencies hasn’t helped.

I am finding myself with a stock installation with the latest stable versions of both AS and Kotlin yet showing a very unsmooth behaviour which is rather unsatisfying. (I recently read “Kotlin in Action” and can’t wait to get started). I am hoping you can provide me with some solution that shows where I went wrong and get me back on track with my enthusiasm.

For the sake of completeness my gradle.build file:

buildscript {
ext.kotlin_version = '1.0.5-3’
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath ‘com.android.tools.build:gradle:2.2.3’

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}


#2

The first item in the tutorial tells you that you need to install the Kotlin plugin.

Which exactly version of the plugin do you have installed, and which version of Android Studio are you using?