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

FOREIGN KEY constraint failed on loading of default mesh network #593

Open
mpiffari opened this issue Oct 25, 2024 · 1 comment
Open

FOREIGN KEY constraint failed on loading of default mesh network #593

mpiffari opened this issue Oct 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mpiffari
Copy link

mpiffari commented Oct 25, 2024


Hi @dinesharjani and @philips77,
In my KMM app, which is consuming the Android-nRF-Mesh-Library, after reception of MeshManagerCallabacks

  • onNetworkUpdated
  • onNetworkLoaded

nRF Mesh library is getting a fatal exception accessing the DB.
I'm getting this exception during the verify initial startup and initialization of mesh manager API.
It seems like the database is missing required records that violate foreign key dependencies in the Room database used by the library.
Furthermore, is there any way to avoid the default creation of a new mesh network by default during library initialization?
Another point is: where is stored this DB? Can I look directly to it?
NRF Mesh Android/iOS provide some API in order to reset this DB?
Which is the password to use in order to export mesh_network_database.db? And where I can it?

NOTE: on my phone I've also installed an instance of "nRF Mesh" app for Android.


Platform details:

implementation("androidx.sqlite:sqlite-bundled:2.5.0-alpha10")


Logs / Screenshots
Exception stack trace:

2024-10-25 18:17:01.980 22885-22942 AndroidRuntime app E  FATAL EXCEPTION: 
pool-3-thread-2
Process: app, PID: 22885
android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787 SQLITE_CONSTRAINT_FOREIGNKEY)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:961)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:89)
at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(FrameworkSQLiteStatement.android.kt:38)
at androidx.room.EntityInsertionAdapter.insertAndReturnId(EntityInsertionAdapter.android.kt:100)
at no.nordicsemi.android.mesh.data.ApplicationKeyDao_Impl.insert(ApplicationKeyDao_Impl.java:112)
at no.nordicsemi.android.mesh.MeshNetworkDb.lambda$insert$11(MeshNetworkDb.java:248)
at no.nordicsemi.android.mesh.MeshNetworkDb$$ExternalSyntheticLambda28.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
@philips77
Copy link
Member

Hi, let's wait for @roshanrajaratnam to come back.

Btw, you may check the database using Android Studio. Have a look at: https://developer.android.com/studio/inspect/database

@philips77 philips77 added the bug Something isn't working label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants