Hello, i have an application that was working fine till a customer upgraded his tablet to Android 5.0. The database was stored on the SD Card, but after the upgrade there is no access to it. I am trying to create the database on the default ultralite database location but with no success. Any help will be appreciated string exStorageDir = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath; Object reference not set to an instance of an object at RetailMobile.Sync.GenerateDatabase (Android.Content.Context ctx) [0x002c3] in d:\Projects\RetailMobile\RetailMobile\Sync.cs:413 at RetailMobile.Main.OnCreate (Android.OS.Bundle bundle) [0x0011e] in d:\Projects\RetailMobile\RetailMobile\Main.cs:132 I tried with any other directory, not only external dir - files path dir, root dir, but always the same. asked 08 Aug '15, 05:59 katalun4o |
Thanks Andy, I found what was causing the problem. The folder that "libultralitej12.so" should be in, must have the same name as the device’s architecture. So if you want to support different architectures you should put the file in all folders - "armeabi", "armeabi-v7a", "x86"... :) answered 19 Aug '15, 14:29 katalun4o 1
Good, but FYI: libultralitej12.so is a native library built for ARM architectures and so will not work on x86. X86 support will be available in SQLA 17.0.
(19 Aug '15, 16:44)
Andy Quick
|
I cannot run the code exactly as given, but I am able to successfully create an UltraLite database with code like this:
Usually, one should put the database in "Android/data/<app-package-name>/files" below the external storage directory.
Also, you must have: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> in your AndroidManifest.xml.
Thank you for the answer Andy. I tried your sample but I got error again. The location I get on my tablet is "/storage/emulated/0/test.udb" and the error is
e {Java.Lang.UnsatisfiedLinkError: Exception of type 'Java.Lang.UnsatisfiedLinkError' was thrown. at Android.Runtime.JNIEnv.CallStaticObjectMethod (IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/7f0e3d3c/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1160 at Com.Ianywhere.Ultralitejni12.DatabaseManager.CreateDatabase (IConfiguration p0) [0x00000] in <filename unknown="">:0 at RetailMobile.Sync.CreateDatabase (Android.Content.Context ctx) [0x0001c] in d:\Projects\RetailMobile\RetailMobile\Sync.cs:76 --- End of managed exception stack trace --- java.lang.UnsatisfiedLinkError: com.ianywhere.ultralitejni12.implementation.JniDbMgr at com.ianywhere.ultralitejni12.DatabaseManager.createDatabase(Unknown Source) at retailmobile.Main.n_onCreate(Native Method) at retailmobile.Main.onCreate(Main.java:33) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) } Java.Lang.UnsatisfiedLinkError
Oh, I was testing UltraLiteJ in SQLA v16. I did try v12 with an arm-v7a Android 5.0 emulator and that worked as well. Are you targeting 64-bit ARM? UnsatisfiedLinkError likely means that the system cannot find the native library, libultralitej12.so. That should be in libs/armeabi in your project.