"Gradle project sync failed" & "Kotlin not configured"


#1

Hi,

I’m totally new to Kotlin and trying to do the setup in Android studio. So far I have done these steps:

  1. Creating a project
  2. Converting Java code to Kotlin
  3. Configuring Kotlin in the project
    I follow this guide: https://kotlinlang.org/docs/tutorials/kotlin-android.html

It works well until step 3 when I get two errors, “Gradle project sync failed” and “Kotlin not configured” (See the picture below). Any ideas what is wrong?

I’m running version 1.0.7.


#2

This may be an issue in Kotlin configuration wizard that is fixed in newer plugin versions.

To fix the problem use org.jetbrains.kotlin:kotlin-stdlib:1.0.7 as a dependency instead of org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7


#3

Thanks for your reply @ilya.gorbunov ! I tried it but it still don’t want to work.

I get the error:
“Error:Could not find kotlin-stdlib-1.0.7.jar (org.jetbrains.kotlin:kotlin-stdlib:1.0.7).
Searched in the following locations:
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib/1.0.7/kotlin-stdlib-1.0.7-1.0.7.jar


#4

:1.0.7 in the end is the version of the library, so there’s no need to append it twice, first as a literal and then as the kotlinVersion variable substitution. Your compile dependency should look like:

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

I suppose $kotlin_version evaluates to 1.0.7 and finally you get org.jetbrains.kotlin:kotlin-stdlib:1.0.7


#5

It solved the problem! Thanks for your help!

/Mattias


#6

I had this in my build.gradle:
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

but I started getting the same error as OP. This started after I quit AS while it was doing something…I might have force quit. Anyway when I click ‘Configure Kotlin’, it adds
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
to the end of the deps.

Is there something I should try to do? Clear cache or delete build files?


#7

This works for me too.
Thank you.