The 3.3.1.1 Xamarin Android download contains a "3.3.1.0" DLL

My project is crashing on Android 6.0 on GenyMotion when accessing SQLCipher with a generic “SQLCipher” exception. The Application output has many failed attempts to find the DLL such as:
‘dlopen failed: library “/data/app/com.myproject/lib/x86/libsqlcipher” not found’.

I had read that there was a Marshmallow incompatibility that was fixed in 3.3.1.1 so I downloaded the “3.3.1.1” zip from the Xamarin Android component store, and when I check the version on the DLL it says “3.3.1.0”.


Is the wrong zip file being hosted on the Xamarin component download page? How can I get the true zip file containing the “3.3.1.1” DLL file?

Hello @Cabrill

We did not rev the assembly version itself with the 3.3.1.1 release as the source did not change from 3.3.1.0. In that particular instance, the only change to the 3.3.1.1 build was the version of the compiler used for the native library, so we just updated the Xamarin component version number.

Are you able to recreate the issue on any other Android 6.0 devices/emulators outside of GenyMotion? Do you see the same issue with the current release of 4.0.0.1?

Yes, @developernotes, I tried launching the app on my personal LG G4 running Android 6.0, and it also crashes with a ‘SQLCipher’ exception when attempting to create the SQLiteConnection. I had the same problem when using the 4.0.0.1 version, but I wasn’t sure if that was because I needed to perform a migration to 4.X for the DB and didn’t want to have to migrate if an earlier version contained the Marshmallow fix. The 3.3.1.1 version does work on all earlier versions of Android, but crashes on 6.0 on both emulator and my physical device.

Hi @Cabrill

There were no changes to the database file format between those versions, however the client API changed when we introduced 4.0.0.0 so you would need to update that. Are you able to reproduce the error with the trial application provided within the component store?

No, the trial application appears to work on both emulator and physical device. The only difference I can see is in how the connection is initialized. The trial uses:
var conn = new SqliteConnection(String.Format("Data Source={0}", databasePath)); conn.SetPassword(password);

and my application initializes the connection like this:
using (new SQLiteConnection (databasePath,password, false))

I’m unsure why that would cause an incompatibility between different Android versions but I’ll attempt to duplicate the example connection code in my own project and let you know if that resolves the crash. Thank you for your assistance, @developernotes.

Hello @Cabrill

The trial uses the Mono.Data.Sqlcipher client library (the older version of SQLCipher for Xamarin Android and iOS shipped with two different client libraries). It may be worth adjusting the trial sample to use the SQLiteConnection so it is using the sqlite-net client library, just to verify whether the issue is isolated to your application or the library itself.

Hi @developernotes, I was able to recreate the crash in the trial application by changing the connection type to SQLiteConnection, and changing the project’s Target Framework to ‘Android 6.0(Marshmallow)’. Please let me know if you’d like me to upload the modified project anywhere or if you’re able to confirm the crash using this information. Thank you.

Just an update, I’ve confirmed this crash occurs on the trial project included with version 4.0.0.1, too, with no changes other than changing the target platform.

Hello @Cabrill

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. Can you verify that addresses the issue on your end? Thanks!

Thank you, yes that does resolve the issue. So the SQLCipher libraries just don’t currently support x64 on Android 6.0 then?

Hello @Cabrill

I’m glad to hear that resolved the issue on your end. SQLCipher for Xamarin Android uses OpenSSL which does not support building x64 for Android natively yet without modifications to their build process. We look forward to adding future platform support when OpenSSL supports it.

@developernotes, I’m sorry to say I was mistaken. When I reported back earlier I had forgotten to switch which emulator I was currently running from Android 5.1 to 6.0. After trying to deploy it to my physical device and it crashing (with only armeabi, armeabi-v7a, and x86 selected) I realized that I had tested on the wrong version of Android when I reported back to you it was fixed. The SqlCipher trial program still crashes on Android 6.0 even when 64-bit deploy options are unchecked.

Hello @Cabrill

I just ran the 4.0.0.1 demo program on a Nexus 9 device running OS 6.0.1 (MMB29R) with only armeabi, armeabi-v7a, and x86 selected, the application ran properly. Do you have any other 6.0 devices available to verify whether the issue is isolated to your specific device? I would like to narrow this down further, however I haven’t been able to reproduce it.

Thank you, @developernotes. Unfortunately the LG G4 is the only physical device I own with Android 6.0 installed. However, you should be able to recreate it using the free-for-personal-use Genymotion software and use the Nexus 9 Android 6.0 image. After changing the ‘Target Android version’ from ‘Auto’ to ‘Override - Android 6.0 (API level 23)’ on the 4.0.0.1 demo program, it should result in the same crash I’m reporting regardless of the ABIs that have been selected.

Hello @Cabrill

I think I may have narrowed down what may be causing the crash, although I’m not certain if the bug is within Xamarin itself, or something else. The default target framework within Build → General was set to Android 4.4. If you leave the Build → General to 4.4, then modify the Build → Android Application configuration to have a Minimum Android Version to API 10 (to support the device), and target Android version to Android 6.0, I receive the crash. However, if you modify the Build → General target framework and set it to Android 6.0, then adjust Build → Android Application minimum Android version to 10, and set target Android version to Automatic, or Android 6.0 the application works properly. Would you give that a try when you get the opportunity? Thanks!

You are correct that it does not crash if the ‘Target Android version’ is set to Automatic, but if it is set to ‘Android 6.0 - API23’ then it still crashes for me. The change in minimum Android version doesn’t seem to impact it either way, although on the app I’m developing the minimum version is set to ‘Android 4.0 - API14’ because I use Xamarin Forms which does not support older APIs. I’m not sure whether the cause is Xamarin or SQLCipher either, but my assumption is that allowing ‘Auto’ enables Xamarin to choose a lower target than Marshmallow because it detects the SQLCipher library won’t support API23, so when you override the setting to specify API23 it results in the crash.

Hi @Cabrill

What value do you have specified in your Build → General → Target framework? I needed to set mine to Android 6.0 in order to allow Build → Android Application → Target Android version to specify Automatic (use target framework version API 23) which works. We currently use NDK r9d to build the native libraries for SQLCipher for Xamarin Android as the newer versions of the NDK introduced a compiler bug for the x86 platform.

Sorry for the long delay in response. Setting the API to automatic does allow me to build, as I’ve said previously, but I’ve already published a version of my app targeting API 23 and the Google Play Store will not allow me to “downgrade” it to an API of “Auto.” I realize the Auto says “Automatic - use target framework version (API23)” however that apparently isn’t the same thing as targeting API23, and once you’ve targeted API23 Google Play Developer console will not allow a target of “Auto”. So it needs to be set to API23 to allow me to continue publishing, but using API 23 causes SQLCipher to crash. Here are more details on the publishing limitation: Target API cannot be downgraded on Google Developer Console and API23 uses new permissions, cannot revert to API22

The specific error I get from Google is:
“It is forbidden to downgrade devices which previously used M permissions (target SDK 23 and above) to APKs which use old style permissions (target SDK 22 and below). This occurs in the change from version 184 (target SDK 23) to version 193 (target SDK 0).”

Hi @Cabrill

The issue appears to have been addressed by Xamarin within their Xamarin.Android 6.1 release, their release notes here reference bug #34391 (System.DllNotFoundException: sqlcipher). I switched over to the Alpha channel, however that only installs Xamarin.Android 6.0.99.544 so they don’t appear to have made 6.1 publicly available yet.

Thank you, I had found that bug report previously but didn’t think it was applicable since the bug report specifically mentions using the native libraries and it being the .SO files that were not having the proper build action taken upon them. I’ll hope for a 6.1 release soon so I can confirm it fixes the problem and report back.