hi, I keep getting this error when building my mul...
# multiplatform
m
hi, I keep getting this error when building my multiplatform library.
WeakReference
is an expect class that already implemented on
jvmMain
. code in thread 🧵
Copy code
> Task :bindable-lib:compileDebugKotlinAndroid FAILED
e: file:///xxxx/bindable/bindable-lib/src/commonMain/kotlin/moe/ganen/bindable/WeakReference.kt:3:21 Expected class 'WeakReference' has no actual declaration in module <bindable-lib_debug> for JVM

> Task :bindable-lib:compileReleaseKotlinAndroid FAILED
e: file:///xxxx/bindable/bindable-lib/src/commonMain/kotlin/moe/ganen/bindable/WeakReference.kt:3:21 Expected class 'WeakReference' has no actual declaration in module <bindable-lib_release> for JVM
expect declaration
Copy code
public expect class WeakReference<T : Any>(referred: T) {
    public fun clear()

    public fun get(): T?
}
actual declaration on
jvmMain
Copy code
public actual class WeakReference<T : Any> actual constructor(referred: T) : WeakReference<T>(referred)
also to put in context, I'm targeting jvm and android sourceset only
j
Both are independent source sets
You need to add the actual to android one too, or add a shared folder to both source sets
👍 1
m
aha, I thought you don't need to declare the actual on Android set since the IDE only ask actual on
jvmMain
. adding the actual implementation on Android fixed it. thank you