0

I'm using the AssetSQLiteOpenHelper library on an Android application but when creating a new instance of the AssetSQLiteOpenHelperFactory class in the following context:

RoomDatabase.Builder<AppDatabase> builder = Room.databaseBuilder(
    context.getApplicationContext(), 
    AppDatabase.class,context.getString(R.string.database_name));

return (builder.openHelperFactory(new AssetSQLiteOpenHelperFactory())
    .allowMainThreadQueries()
    .addMigrations(MIGRATION_1_2).build());

I receive the error:

'openHelperFactory(androidx.sqlite.db.SupportSQLiteOpenHelper.Factory)' in 
'androidx.room.RoomDatabase.Builder' cannot be applied to 
'(com.fstyle.library.helper.AssetSQLiteOpenHelperFactory)'

This is contrary to what the documentation states(click here to view their documentation).

I have made sure to include their dependency in the build.gradle file via:

implementation 'com.github.daolq3012:AssetSQLiteOpenHelper:V1.0.1'

I have tried 'Clean Project' -> 'Rebuild Project' and the 'Invalidate caches/Restart` options with no success.

Keep in mind I am answering this question myself as I have found a solution and want to share it with anyone else who might run into the same issue.

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25

1 Answers1

0

Adding the following lines to the gradle.properties file then syncing the project with the Gradle files solved this problem:

android.useAndroidX=true
android.enableJetifier=true

I think this error was caused by migration issues when migrating from Support Libraries to AndroidX, therefore enabling Jetifier resolved it.

Here is a link to a helpful SO answer on what android.enableJetifier=true does: android - What is Jetifier?

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25