Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 1683 [details]
I'm trying to include a standard sqlite library in my application in order to support different Android versions.
For exemple, Android 2.1's sqlite version does not include function like sqlite3_config, sqlite3_next_stmt.
I added an ARM libsqlitecustom.so (extracted from my Android 2.3 device) in my project under lib/armeabi.
I set the libsqlitecustom.so to AndroidNativeLibrary.
If I call :
[DllImport("libsqlitecustom", EntryPoint = "sqlite3_config")]
public static extern Result Config (ConfigOption option);
I always get a DllNotFoundException. I've tried with "libsqlitecustom.so", "sqlitecustom", "sqlitecustom.so", "lib/armeabi/libsqlitecustom" etc
How to reproduce:
Compile and start the repro project and you'll get the DllNotFoundException.
I get this exception on all my devices (Android 2.1, 2.2, 2.3).
How are you building libsqlitecustom.so? I don't think that it's valid. I say this for two reasons:
1. If I enable Mono's native library logging:
adb shell setprop debug.mono.env MONO_LOG_LEVEL=info
I get the following on `adb logcat`:
> D/Mono (18754): DllImport attempting to load: 'libsqlitecustom'.
> D/Mono (18754): DllImport loading library: '/data/data/BundleNativeLibrary.BundleNativeLibrary/files/.__override__/libsqlitecustom'.
> D/Mono (18754): DllImport error loading library 'Cannot load library: load_library: Library '/data/data/BundleNativeLibrary.BundleNativeLibrary/lib//data/data/BundleNativeLibrary.BundleNativeLibrary/files/.__override__/libsqlitecustom' not found'.
> D/Mono (18754): DllImport loading library: '/data/data/BundleNativeLibrary.BundleNativeLibrary/files/.__override__/libsqlitecustom.so'.
> D/Mono (18754): DllImport error loading library 'Cannot load library: load_library: Library '/data/data/BundleNativeLibrary.BundleNativeLibrary/lib//data/data/BundleNativeLibrary.BundleNativeLibrary/files/.__override__/libsqlitecustom.so' not found'.
> D/Mono (18754): DllImport loading location: 'libsqlitecustom'.
> D/Mono (18754): DllImport error loading library: 'Cannot load library: load_library: Library '/data/data/BundleNativeLibrary.BundleNativeLibrary/lib/libsqlitecustom' not found'.
> D/Mono (18754): DllImport loading location: 'libsqlitecustom.so'.
> D/Mono (18754): DllImport error loading library: 'Cannot load library: reserve_mem_region: OOPS: 67 prelinked library 'libsqlitecustom.so' mapped at 0x48000000, not at 0xa8b00000'.
We probe several different files and directories, but the valie one -- libsqlitecustom.so -- fails:
prelinked library 'libsqlitecustom.so' mapped at 0x48000000, not at 0xa8b00000
2. So sanity-check the .so (this isn't perfect, but it's a useful guideline):
-lm -lc -lz -ldl -llog
(Change/update the -lfoo lines to list every native library that libsqlitecustom.so was linked against.)
The above command lists 33 unresolved symbols, e.g.
lib/armeabi/libsqlitecustom.so: undefined reference to `utf32_at'
You need to use the NDK toolchain to build libsqlitecustom.so, and only link against native libraries that are included with the NDK or themselves linked against the NDK.
I extracted the libsqlite.so from my device (adb pull /system/lib/libsqlite.so) and then I tried to load it in my application as a AndroidNativeLib (on the same device).
I though that the library would be ok, but maybe I should build my own libsqlite.so.
Thank for the advice.