Thursday, November 12, 2015

Kotlin Gradle Blooper!

This weekend I had a blast working through the Kotlin Koans, so I thought I'd fire up my IDE and try my hand at porting one of my existing hobby projects from Groovy to Kotlin.

As I began working on it, I was surprised to notice that some of the cool features from the Koans and other examples online weren't available to me in my project -- things like doing MyClass::class.java, listOf(), and even forEach on my List<> objects.

My build.gradle file was including the kotlin-gradle-plugin, of course, but if you want all the goodies, you've got to also include the Kotlin Standard Library:


dependencies {
    compile 'org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version_number'
}

Naturally, the instructions for configuring dependencies for the Kotlin Gradle plugin say very clearly to include it, and they even give a full example. I guess in my excitement I just skipped over that part! My bad, yo.

So... if you're a Kotlin newb like me and your code seems to be missing some major Kotlinness, be sure to include the Standard Library!

Leeds out.

Profile Picture
Dave Leeds
My Hobbies:
  • Programming
  • Cartooning
  • Music Writing
Full Profile