Interface in KMM lib

I declared interface in KMM library:

interface Foo {
    fun foo() {}

And class in KMM app in common part:

class Bar: Foo{

And when try create Foo object in android part i got an error like a:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class Bar, unresolved supertypes: Foo

Is it possible use interfaces like above?

It looks like the dependencies in your build.gradle file aren’t correct. Make sure that your android library has a dependency on both the library that contains Bar and the library that contains Foo.
If this doesn’t help you could post the relevant parts of your build.gradle files

Thanks a lot!
Worked with gradle api("some lib"), instead of implementation("some lib")

1 Like