1

I have a simple Android Xamarin project that uses a number of aars. These aars are each built into dlls and then included as references in the main app.

All worked great until we added Room database access to one of the aars. I have the Xamarin.AndroidX.Room.Common and Xamarin.AndroidX.Room.Runtime references added to the project.

Nevertheless I am getting the following error:

java.lang.NoSuchMethodError: No direct method <init>(Landroidx/room/RoomDatabase;Ljava/util/Map;Ljava/util/Map;[Ljava/lang/String;)V in class Landroidx/room/InvalidationTracker; or its super classes (declaration of 'androidx.room.InvalidationTracker' appears in base.apk)
    at roomstorage.database.Database_Impl.createInvalidationTracker(Database_Impl.java:153)
    at androidx.room.RoomDatabase.<init>(RoomDatabase.java:104)
    at roomstorage.database.Database.<init>(Database.java:20)
    at roomstorage.database.Database_Impl.<init>(Database_Impl.java:34)
    at java.lang.Class.newInstance(Native Method)
    at androidx.room.Room.getGeneratedImplementation(Room.java:91)
    at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:667)
    at roomstorage.database.DataModule.createDatabase(DataModule.java:38)
    at roomstorage.database.DataModule.getDatabaseInstance(DataModule.java:25)

The code that uses the database is Kotlin. Not sure if that makes any difference.

theblitz
  • 6,683
  • 16
  • 60
  • 114
  • It seems that the method `androidx.room.InvalidationTracker` from `Xamarin.AndroidX.Room.Runtime` is unavailable. I don't see any dependencies in the android docs either https://androidx.de/androidx/room/InvalidationTracker.html. My guess is there is something wrong with your DLL creation. – FreakyAli Dec 27 '21 at 13:41
  • @FreakyAli The thing is, the code that includes that call is a standard Android aar which is used in other apps. It is used internally by Room when creating a database. – theblitz Dec 27 '21 at 14:00
  • Correct me if I am wrong but what you are saying here is that the code that refers to the Room Runtime is in the AAR? – FreakyAli Dec 27 '21 at 14:03
  • You are correct. – theblitz Dec 27 '21 at 14:04
  • Then you might wanna check this https://stackoverflow.com/a/40997532/7462031 – FreakyAli Dec 27 '21 at 14:05
  • Looks interesting but what is weird is that the method is part of the Room base code and is in the same package as other classes in the same chain. It's almost as if the specific constructor is missing. – theblitz Dec 27 '21 at 14:15
  • It could be an issue of TargetPlatform, maybe you are targeting your application/aar to an API level that does not have the constructor!? Are you aware of any such restrictions? – FreakyAli Dec 27 '21 at 14:19

0 Answers0