Stack Overflow archive
3 score

Run single kotlin class with main function in android studio

score
3
question views
61.3K
license
CC BY-SA 3.0

As mentioned in the issue tracker, a temporary workaround is to add the following to the root build.gradle script:

kotlin
subprojects { subProject ->
    afterEvaluate {
        if (subProject.plugins.hasPlugin("kotlin") && subProject.plugins.hasPlugin("java-library")) {
            subProject.kotlin.copyClassesToJavaOutput = true
            subProject.jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
        }
    }
}

See: https://issuetracker.google.com/issues/68021152#comment12

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.