Xamarin AndroidX RoomDatabase NoClassDefFoundError at runtime

I am trying to create a Xamarin binding for our Android library that uses AndroidX for Room (v2.0.0), and I have successfully compited without errors and warnings; however, it crashes at runtime because androidx.room.RoomDatabase cannot be found. The full stack trace of the error is below.

Java.Lang.NoClassDefFoundError: Failed resolution of: Landroidx/room/RoomDatabase; ---> Java.Lang.ClassNotFoundException: Didn't find class "androidx.room.RoomDatabase" on path: DexPathList[[zip file "/data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/base.apk"],nativeLibraryDirectories=[/data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/lib/x86, /data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/base.apk!/lib/x86, /system/lib]]
  at java.lang.ClassNotFoundException: Didn't find class "androidx.room.RoomDatabase" on path: DexPathList[[zip file "/data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/base.apk"],nativeLibraryDirectories=[/data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/lib/x86, /data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/base.apk!/lib/x86, /system/lib]]
  at at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
  at at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
  at at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  at at com.radiusnetworks.flybuy.sdk.FlyBuy.configure(FlyBuy.kt:44)
  at at com.radiusnetworks.flybuy.sdk.FlyBuy.configure(FlyBuy.kt:52)
  at at md5c4331366950d5a243d8c53ea4b3d5e45.FlyBuyExampleApplication.n_onCreate(Native Method)
  at at md5c4331366950d5a243d8c53ea4b3d5e45.FlyBuyExampleApplication.onCreate(FlyBuyExampleApplication.java:25)
  at at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
  at at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
  at at android.app.ActivityThread.access$1100(ActivityThread.java:199)
  at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
  at at android.os.Handler.dispatchMessage(Handler.java:106)
  at at android.os.Looper.loop(Looper.java:193)
  at at android.app.ActivityThread.main(ActivityThread.java:6669)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
  --- End of inner exception stack trace ---
  at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00089] in <a28ef992ef1c47dba4efa3bd75e0a265>:0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <a28ef992ef1c47dba4efa3bd75e0a265>:0
  at Com.Radiusnetworks.Flybuy.Sdk.FlyBuy.Configure (Android.Content.Context context, System.String baseUrl, System.String appTokenKey) [0x00060] in /Users/tim/Documents/Dev/xamarin/flybuyexample-xamarin-android/FlyBuySDK/obj/Debug/generated/src/Com.Radiusnetworks.Flybuy.Sdk.FlyBuy.cs:206
  at FlyBuyExampleAndroid.FlyBuyExampleApplication.OnCreate () [0x00008] in /Users/tim/Documents/Dev/xamarin/flybuyexample-xamarin-android/FlyBuyExampleAndroid/FlyBuyExampleApplication.cs:28
  at Android.App.Application.n_OnCreate (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <b62c3fba3fe848f3bb323dbe33464223>:0
  at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr)
  at java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/room/RoomDatabase;
  at at com.radiusnetworks.flybuy.sdk.FlyBuy.configure(FlyBuy.kt:44)
  at at com.radiusnetworks.flybuy.sdk.FlyBuy.configure(FlyBuy.kt:52)
  at at md5c4331366950d5a243d8c53ea4b3d5e45.FlyBuyExampleApplication.n_onCreate(Native Method)
  at at md5c4331366950d5a243d8c53ea4b3d5e45.FlyBuyExampleApplication.onCreate(FlyBuyExampleApplication.java:25)
  at at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1154)
  at at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5871)
  at at android.app.ActivityThread.access$1100(ActivityThread.java:199)
  at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
  at at android.os.Handler.dispatchMessage(Handler.java:106)
  at at android.os.Looper.loop(Looper.java:193)
  at at android.app.ActivityThread.main(ActivityThread.java:6669)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
  at Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.room.RoomDatabase" on path: DexPathList[[zip file "/data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/base.apk"],nativeLibraryDirectories=[/data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/lib/x86, /data/app/com.radiusnetworks.CLPExampleAndroid.FlyBuyExampleAndroid-W3mw1PpDGTIJDcuSU6macg==/base.apk!/lib/x86, /system/lib]]
  at at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
  at at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
  at at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  at ... 14 more
Sign In or Register to comment.