0

Recently I've encountered an odd problem/bug in IntelliJ IDEA during developing my Android library in Kotlin. I have 2 library modules inside a dummy app. module1 imports module2 which has extension functions.

I applied Kotlin plugins into module1 so the first lines of module's build.gradle look like this:

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

After that I got the following build error when trying to export the artifact to .jar:

Error:Kotlin: Unsupported plugin option: org.jetbrains.kotlin.android:enabled=true

What's really weird is that when I remove one of the Kotlin plugins, e.g. kotlin-android-extensions, that error no longer occurs. Instead, no extension function from module2 can be resolved (obviously.)

Error:(x, y) Kotlin: Unresolved reference: extensionFunctionFromModule2

Other classes can be resolved and everything would work without extension functions.

Additional info

When I removed only kotlin-android plugin everything was being built successfully... for a very short time. The very next day I suddenly got errors about extension functions' references again.

Am I doing something wrong or is it a bug of IntelliJ IDEA/Kotlin/Gradle? Seeing that strange behavior (the fact that two Kotlin plugins cannot be applied at the same time) I assume it's some kind of bug. (Maybe caching?) Especially that with application projects everything works just fine. Unfortunately I cannot say how it was working previously as it's my first library project and modules.

module1's build.gradle

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation project(path: ":module2")
}
repositories {
    mavenCentral()
}

module2's build.gradle

The same as module1's but without line with implementations of module2, obviously.

App's build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    ext.anko_version = '0.10.8'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle.properties

org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

IDE version

IntelliJ IDEA 2019.2.2 (Community Edition)
Build #IC-192.6603.28, built on September 6, 2019
2
  • Please report at youtrack.jetbrains.com/issues/KT with the sample project to reproduce attached. Commented Sep 15, 2019 at 3:40
  • 1
    Done. For everyone who's struggling with the same problem, here is the issue at YouTrack: link Commented Sep 15, 2019 at 9:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.