I am inserting some data in the SQLite Database using room in the following manner:
Method for inserting data in the repository class:
fun addAllConfigurableTypeToDb(
allConfigurableTypes: AllConfigurableType,
database: AppDatabase
): Boolean {
try {
val productCategoryList = arrayListOf<ConfigurableTypeEntity>()
for (configurableType in allConfigurableTypes.configurableTypeList) {
productCategoryList.add(
ConfigurableTypeEntity(
configurableType.id, configurableType.classType,
configurableType.organizationId, configurableType.name,
configurableType.code, configurableType.description,
configurableType.context, configurableType.isActive,
configurableType.isLocked, configurableType.isDeleted,
configurableType.createdBy, configurableType.createdByDate,
configurableType.lastModifiedBy, configurableType.lastModifiedByDate
)
)
}
database.configurableTypeDao.insertAll(*productCategoryList.toTypedArray())
return true
} catch (e: Exception) {
e.printStackTrace()
return false
}
}
The method inside Dao class:
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(vararg configurableTypeEntity: ConfigurableTypeEntity)
It has been working fine. But after updating room version from '2.5.2' to '2.6.0', ksp version from '1.8.10-1.0.9' to '1.9.20-1.0.14' and kotlin version from '1.8.10' to '1.9.20' I'm getting the follwing exception:
12:16:29.832 W java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.sqlite.db.framework.FrameworkSQLiteProgram.bindString, parameter value
12:16:29.832 W at androidx.sqlite.db.framework.FrameworkSQLiteProgram.bindString(Unknown Source:3)
12:16:29.832 W at <project_package_name>.data.local.dao.ConfigurableTypeDao_Impl$1.bind(ConfigurableTypeDao_Impl.java:53)
12:16:29.832 W at <project_package_name>.data.local.dao.ConfigurableTypeDao_Impl$1.bind(ConfigurableTypeDao_Impl.java:35)
12:16:29.832 W at androidx.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.kt:83)
12:16:29.832 W at <project_package_name>.data.local.dao.ConfigurableTypeDao_Impl.insertAll(ConfigurableTypeDao_Impl.java:99)
12:16:29.832 W at <project_package_name>.data.repository.SyncAllRepository.addAllConfigurableTypeToDb(SyncAllRepository.kt:175)
12:16:29.832 W at <project_package_name>.viewModel.SyncAllViewModel$syncConfigurableTypesTable$1.invokeSuspend(SyncAllViewModel.kt:201)
12:16:29.832 W at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
12:16:29.832 W at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
12:16:29.832 W at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
12:16:29.832 W at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:100)
12:16:29.832 W at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
12:16:29.832 W at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
12:16:29.832 W at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
12:16:29.832 W at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
NOTE: in the log, the line SyncAllRepository.kt:175 is the line return true of the addAllConfigurableTypeToDb method.
My currrent project level build.gradle looks like this:
plugins {
id 'com.android.application' version '8.1.3' apply false
id 'com.android.library' version '8.1.3' apply false
// id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
id 'com.google.devtools.ksp' version '1.9.20-1.0.14' apply false
id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
// id 'com.google.devtools.ksp' version '1.8.10-1.0.9' apply false
// id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}
If I undo the changes in room version, ksp version and kotlin version, the project works fine. But why am I getting the error after using the latest versions? What other changes should I make so that I don't get this exception?
Please note that the productCategoryList in addAllConfigurableTypeToDb() is not null. In Dao's insertAll() I've tried using List instead of vararg but I still got the same result.