Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Android Binding Library - Exception when trying to use Kotlin coroutines.

SListSList USMember ✭✭
edited July 2019 in Xamarin.Android

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 Kotlin coroutines.
Is there any support for Kotlinx-coroutines in a Xamarin Android Binding library?

Best Answer

Answers

  • SListSList USMember ✭✭

    I tried adding the kotlin coroutine jars to my Android Binding Library as dependencies (reference JARs), but I got a lot of build errors in the generated C# code. This is a rabbit hole down which I don't want to go.

  • AlexeyShikovAlexeyShikov UAMember ✭✭

    Hey @SList! Have you moved any further or just dropped the idea of making bindings?

  • SListSList USMember ✭✭
    Accepted Answer

    I used Java instead. :-) Sorry!

Sign In or Register to comment.