I started off with the tutorial for learning Kotlin in IntelliJ
.When I tried running the example i.e
fun main(args: Array) {
prin
My problem was solved by adding kotlin
as follow
presentation.gradle (app.gradle)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' // here
apply plugin: 'kotlin-android-extensions' // and here
android {
...
}
dependencies {
...
}
domain.gradle (pure kotlin)
My error was throw here, because Android Studio create my domain module as pure Java Module and applied plugin as java, and I used it in the my presentation module that is a Android/Kotlin Module
The Android Studio finds and import the path of package but the incompatibillity don't allow the build.
Just remove
apply plugin: 'java'
and swith to kotlin as follow
apply plugin: 'kotlin' // here is
dependencies {
...
}
...
data.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' // here
apply plugin: 'kotlin-android-extensions' // and here
android {
...
}
dependencies {
..
}
I think that it will be helpfull
I tried everything: clean build folders, run gradle clean build
, execute AS invalidate cache(x2), reinstall Kotlin plugin, restarting pc.
But in the end after doing all this it still didn't work, but doing also removal from project build.gradle
of this line: apply plugin: 'kotlin-android-extensions'
, gradle sync and then re-adding worked
Invalidating caches and updating the Kotlin plugin in Android Studio did the trick for me.
Another thing I would like to add is that you need to select View -> Tool Windows -> Gradle before you can run the project using the Gradle.
If using the Gradle the project builds and runs normally but using the IntelliJ it doesn't, then this can solve the matter.
Check and install Android Studio Updates. This fix the problem.
For me, it was due to the project missing Gradle Libraries in its project structure.
Just add in build.gradle:
apply plugin: 'idea'
And then run:
$ gradle idea
After that gradle rebuilds dependencies libraries and the references are recognized!