I'm not able to use top level functions from my custom Kotlin library

Viewed 475

I wanted to create a kotlin library for android that contains a few top-level functions.

I've created an android library project.

I've added a few top-level functions and a few classes

// filename TestMethodFirst.kt
fun testMethodFirst() {}
// filename TestClass.kt
class TestClass() {}

I've built the library with the ./gradlew build

I've included this library to another project as an aar library

The classes from the library were resolved and imported without a problem. The top-level functions were unresolved so they couldn't be used. I've tried to add import manually but it wasn't working either. When I tried to use top-level functions from the java, as a static method execution, then it was working.

This doesn't work

// filename Test1.kt
fun test1() {
    testMethodFirst()
}

This works

// filename Test2.kt
fun test1() {
    TestClass()
}

This works

// filename Test3.java
class Test {
    void test() {
        TestMethodFirstKt.testMethodFirst();
    }
}

I've tried it with the AS 4.1 Canary 7 and with AS 3.6.2

Attachments contain the library project and the aar library

Project

Generated aar

1 Answers
Related