4

I have an Android Binding Library with Kotlin code, and it exits whenever it hits runBlocking{} in the Kotlin code.

E(28583:28691) ERROR [19] - The worker thread caught an exception: Failed resolution of: Lkotlinx/coroutines/BuildersKt; E(28583:28691) Java.Lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/BuildersKt; ---> Java.Lang.ClassNotFoundException: Didn't find class "kotlinx.coroutines.BuildersKt" on path: DexPathList[[zip file "/data/app/de.mycompany.app.myproduct-1/base.apk"],nativeLibraryDirectories=[/data/app/de.mycompany.app.myproduct-1/lib/arm, /vendor/lib, /system/lib]]

In my Kotlin AAR module, I have the following dependencies

implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
=> equivalent Xamarin.Kotlin.StdLib
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
=> equivalent Xamarin.????
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1"
=> equivalent Xamarin.????

I'm guessing that Xamarin.Kotlin.StdLib doesn't include support for the Kotlinx coroutines.
Is there any way to get support for Kotlinx-coroutines in a Xamarin Android Binding library?

1 Answer 1

1

You're right, Xamarin.Kotlin.StdLib doesn't include support for the Kotlinx coroutines.

In order to have the Kotlinx-coroutines in a Xamarin Android Binding library, you have to add the KotlinX.Coroutines NuGet package as a dependency of the app project and the binding library project.

So if you have something like this:

MyAndroidApp.proj -> MyBindingLibrary.proj

Both project have to add the KotlinX.Coroutines dependency.

N.B. In my case, Microsoft's binding was NOT working. I had to use Karamunting's binding.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.