Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal crash in API 35 from FileNotFoundException on init call #1741

Open
shobhik opened this issue Jul 16, 2024 · 3 comments
Open

Fatal crash in API 35 from FileNotFoundException on init call #1741

shobhik opened this issue Jul 16, 2024 · 3 comments

Comments

@shobhik
Copy link

shobhik commented Jul 16, 2024

Hi there,

DBFlow Version: 4.2.4

Bug or Feature Request: Bug for sure

Description: When pushing to API 33 on a fresh install, I get an exception on FlowManager.init() but the new DB is successfully initialized. When pushing to a VM with API 35, there is a fatal crash with an identical stacktrace.

20:01:49.166  5280-5280  FlowLog                 com.example.myapp  E  java.io.FileNotFoundException: MyDbFile.db
                                                                                         	at android.content.res.AssetManager.nativeOpenAsset(Native Method)
                                                                                         	at android.content.res.AssetManager.open(AssetManager.java:904)
                                                                                         	at android.content.res.AssetManager.open(AssetManager.java:881)
                                                                                         	at com.raizlabs.android.dbflow.structure.database.DatabaseHelperDelegate.restoreDatabase(DatabaseHelperDelegate.java:261)
                                                                                         	at com.raizlabs.android.dbflow.structure.database.DatabaseHelperDelegate.performRestoreFromBackup(DatabaseHelperDelegate.java:53)
                                                                                         	at com.simplebutneeded.android.commons.database.SQLCipherOpenHelper.performRestoreFromBackup(SQLCipherOpenHelper.java:73)
                                                                                         	at com.raizlabs.android.dbflow.config.DatabaseDefinition.getHelper(DatabaseDefinition.java:250)
                                                                                         	at com.raizlabs.android.dbflow.config.DatabaseDefinition.getWritableDatabase(DatabaseDefinition.java:257)
                                                                                         	at com.raizlabs.android.dbflow.config.FlowManager.init(FlowManager.java:324)
                                                                                         	at com.example.myapp.database.MyDatabaseInitializer.initializeDatabase(MyDatabaseInitializer.java:68)
@shilpidaswani
Copy link

Hey @shobhik facing the same issue, did you find a solution or any workaround?
I am pointing to API 35

@shilpidaswani
Copy link

okay I found the solution that works like a charm

instead of calling
FlowManager.init()

call
FlowManager.init(new FlowConfig.Builder(this).build());

because the 'com.github.raizlabs.dbflow' v 3.++ above expects 1 argument
check this out " public static void init( @nonnull com. raizlabs. android. dbflow. config. FlowConfig flowConfig )
Initializes DBFlow, loading the main application Database holder via reflection one time only. This will trigger all creations, updates, and instantiation for each database defined."

@shobhik
Copy link
Author

shobhik commented Sep 25, 2024

@shilpidaswani thanks for following up!

So the way we were using DBFlow was actually using that method signature you mentioned earlier. It was crashing in API 35 Beta 1, but it doesn't crash anymore with API 35 Beta 3, which I believe is now the stable version. We still get an exception in the logs, but it's no longer fatal.

Whew!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants