rafi0101 / Android-Room-Database-Backup

Simple tool to backup and restore your room database in Android
MIT License
239 stars 19 forks source link

Getting crash while integrated with hilt dragger #23

Closed nishkul closed 1 year ago

nishkul commented 1 year ago

java.lang.ClassCastException: dagger.hilt.android.internal.managers.ViewComponentManager$FragmentContextWrapper cannot be cast to androidx.activity.ComponentActivity at de.raphaelebner.roomdatabasebackup.core.RoomBackup.(RoomBackup.kt:696)

pingothedoer commented 1 year ago

Hey @nishkul , did you find any solution? I was trying to do backup in WorkManager using CoroutineWorker and got the similar error. I guess it's about RoomBackup instance creation with context. @rafi0101 Is there any workaround?

nishkul commented 1 year ago

I was calling the wrong way, it should have called before clicking lister backup = RoomBackup(MainActivity@this), which solved the crash for me. tried on both activity and fragment

rafi0101 commented 1 year ago

@nishkul nice that you have found out the solution by yourself This is already content of my documentation: https://github.com/rafi0101/Android-Room-Database-Backup#properties