Xamarin - Unauthorized access to libsqlite.so

Hi all,

I am developing a Xamarin Forms application using Couchbase Lite v1.4 as local database.
Currently I am getting the well-known issue about “unauthorized access to libsqlite.so” on Android N devices.
I’ve seen that I need to use the NuGet package Couchbase.Lite.Storage.CustomSQLite instead of the old native Couchbase.Lite.Storage.SystemSQLite.

I’ve installed CustomSQLite but I am still getting the same error message. Besides, I’ve tried to uninstall the package SystemSQLite but it is defined as a dependency of Couchbase.Lite. Therefore now I have both packages installed and it seems that Couchbase is using the system one.

Is there any additional action to be done for consuming CustomSQLite instead of SystemSQLite?

Did you add the line Couchbase.Lite.Storage.CustomSQLite.Plugin.Register() ? If not it will continue to use the default one (System SQLite). The reason it is a dependency is because it is the default.

2 Likes

Thank you @borrden!

That was the missing stuff :slight_smile:
Now it’s working smoothly.

One last question, on Android < 7 do you recommend still using Couchbase.Lite.Storage.SystemSQLite?

Either one will be fine. It’s the same code path, just with a swapped out native library underneath.

1 Like

I tried but I can’t remove SystemSQLite, I ended up having both CustomSQLite & SystemSQLite together.

Anyway, it works. :no_mouth:

Couchbase.Lite.Storage.CustomSQLite.Plugin.Register()
where should be add this line? when i add it at app_start,the app can’t load in.

That’s where you should add it. If something is going wrong then please be more specific.

“unauthorized access to libsqlite.so

I am geting this error without adding customsqlite in android N devices, how should I resolve this error?

There are only default packages come with couchbase lite, still this error is coming can you let me know how to fix this?

You resolve this by adding th custom SQLite package and calling it’s plugin register method. System SQLite simply won’t work on those devices. That’s google’s decision.

Thanks for the reply @borrrden . I installed custom sqlite package in android project and write the below in line in mainactivity.cs

        Couchbase.Lite.Storage.CustomSQLite.Plugin.Register();

Still I am getting the error mentioned below on android N devices.
“unauthorized access to libsqlite.so

Can you let me know what I am still doing wrong?

Thanks in advance.

Have you cleaned, erased, reinstalled, etc the project and put in a breakpoint to make sure that the line is actually being called? I haven’t heard any issues like this before and calling that method is all you need to do to ensure that the custom sqlite plugin gets used instead.

Hi @borrrden ,

when I tested that in release mode, it’s working and that alert is gone. So customsqlite is working. Don’t know why it’s not working in debug mode.

@aalvarez I am facing the same issue, in my project I have reference added to Couchbase.Lite (version: 1.1.0.17194). Now if I add the reference to Couchbase.Lite.Storage.CustomSQLite, it will create reference related issues as I have to remove Couchbase.Lite. Is there any way to keep this both reference or add a single reference which will server both the purposes of exiting behaviour and removing warning “Unauthorized access to libsqlite”

You are out of luck with that version of Couchbase Lite. It was release in June 2015 before the Android requirement not to access SQLite. I’d strongly recommend updating to a version that hasn’t been out of extended support for almost 18 months (The entire 1.x line is past its end of life)