Skip to content

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

@mpiffari

Description

@mpiffari

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions