Kotlin-android Gradle plugin for android libraries


#1

Hi,

Has anybody managed to compile an android library with gradle?

I have tried to use the ‘kotlin-android’ plugin, but it seems to only work for android modules, not android library modules.

I get the following error:

Gradle: Execution failed for task ‘:cloud:compileDebugKotlin’.
> Plugin with id android has not been used.

I looked at the code for the plugin, and I think I found the source of the problem:

KotlinPlugin.kt:line 244
(https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt)

It calls project.getPlugins().getPlugin(“android”) and expects null if “android-library” is used, in which case it then calls getPlugin(“android-library”)

According to the gradle doc, getPlugin() throws an exception instead of returning null. .hasPlugin() should be used instead to check if a plugin is used or not.

I have created an issue in youtrack:
http://youtrack.jetbrains.com/issue/KT-3911


#2

Thank you for detailed report! Feel free to fix it and send us a pull request :)


#3

Hi,

Thanks for reporting the issue. Fix is on the way.


#4

Fixed in kotlin-gradle-plugin ver. 0.6.69

Thanks again for the report!