Cannot connect to db using mono.data.sqlcipher

Hi,

I have downloaded the sqlcipher trail package for Xamarin.Android from the Xamarin Component Store and I’m trying to connect to a sqlite database using mono.data.sqlcipher, but I just cannot connect to the database. The error message that I get is just “sqlcipher” when I try to open the connection.

The database that I’m using is created with help System.Data.Sqlite in a. NET application. The database is not protected by a password, and I can open it without any problem in my Xamarin.Android app using Mono.Data.Sqlite.

This is the code that I’m trying to get to work:

connectString = @"Data Source=/data/data/com.blaise.depandroid/files/RuntimeConfiguration.db;";
var conn = new Mono.Data.Sqlcipher.SqliteConnection(connectString);
conn.SetPassword("");
conn.Open();  //Fails with errormessage "sqlcipher"

When I use Mono.Data.Sqlite instead the connection is opened without a problem.

Any help is greatly appreciated.

Thanks, Arno

Hello @Arno

What device are you deploying the application to? Can you adjust your project Options within the Android Build → Advanced tab section, please make sure you only have armeabi, armeabi-v7a, and x86 selected as the supported ABI’s?

Hi Nick,

I’m deploying to a Genymotion virtual machine in Windows 10. Must I use a physical device to make sqlcipher work?

armeabi, armeabi-v7a, and x86 are selected in my project options

Thanks, Arno

Hi @Arno

SQLCipher for Xamarin will work on Genymotion, which emulator are you using? Are you including other 3rd party libraries with your application you are testing?

Hi,

I’m using the Google Nexus 7 Android 4.4.4 API 19 emulator.and I’m not using a third party library.

Maybe there is something wrong with my project references: I have referenced SQLite.Net, SQLite.Net.Platform.SQLCipher.XamarinAndroid and SQLite.Net.Platform.XamarinAndroid
.

Hello @Arno

Were you unable to run the demo application that is provided directly with the trial within the Xamarin component store?

Hi,

I figured out what was wrong. I had added the references to my class library (where the connection with the database is created) only, and not to the main app project. After I added the references to my main project the problem was gone. If you don’t do this, you’ll get dllimport errors of several sqlcipher .so files, because the files cannot be found.

Thank you for your help

Hello @Arno

Thank you for getting back to us, we are glad to hear you resolved the issue. Take care!