Kotlin unresolved reference in IntelliJ

后端 未结 20 1465
太阳男子
太阳男子 2020-12-01 08:47

I started off with the tutorial for learning Kotlin in IntelliJ.When I tried running the example i.e

fun main(args: Array) {
 prin         


        
20条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 09:28

    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

提交回复
热议问题