Android Question New SQLCipher 4 with Spatialite

Discussion in 'Android Questions' started by RB Smissaert, Mar 15, 2019 at 9:46 PM.

  1. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Just trying out the new SQLCipher 4, for now with an unencrypted database.
    SQLCipher 4 can connect to this database fine, but there is a problem with Spatialite.
    Spatialite connects to it's own (so a different database file) database, which is unaltered.
    Not sure now what the interaction is between SQLCipher and Spatialite.

    Code:
    Sub Class_Globals
     
     
    Private SPL_Constants As Spatialite_Constants
     
    Private SPL_DB As Spatialite_Database
     
    Private SPLCallBack As Spatialite_Callback
     
    Public strSpatialiteDBName As String
     
    Public strSpatialiteFolder As String
     
    Public strSpatialiteDB As String
     
    End Sub

    Public Sub OpenDB
     
     SPL_DB.Initialize 
    '<<<< error here when using new SQLCipher 3.25.2
     SPL_DB.Open(strSpatialiteFolder, strSpatialiteDBName, SPL_Constants.SQLITE_OPEN_READWRITE)
     
    End Sub
    This is the error I get:

    java.lang.UnsatisfiedLinkError: No implementation found for void jsqlite.Database.internal_init() (tried Java_jsqlite_Database_internal_1init and Java_jsqlite_Database_internal_1init__)
    at jsqlite.Database.internal_init(Native Method)
    at jsqlite.Database.<clinit>(Database.java:1016)
    at uk.co.martinpearman.b4a.spatialite.Database.Initialize(Database.java:76)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at b4a.sqlitelight1.spatialsqlite._opendb(spatialsqlite.java:1625)
    at b4a.sqlitelight1.spatialsqlite._initialize(spatialsqlite.java:71)
    at b4a.sqlitelight1.main$ResumableSub_Activity_Create.resume(main.java:9029)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1746)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:6981)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

    Any idea what the problem could be here?


    RBS
     
  2. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Not sure now what is going on. I reverted back to the old SQLCipher and got the same error. So, this was still with the unencrypted database.
    Then put the old encrypted database back and now get a different error at:

    Code:
    SQL1.Initialize(Starter.strAppDir, strDatabase, bCreate, strPassword, "")
    (SQL1 is SQLCipher)

    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.sqlitelight1-QRkmJsGkJ7LRq6uH8wmM4g==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.sqlitelight1-QRkmJsGkJ7LRq6uH8wmM4g==/lib/arm, /data/app/b4a.sqlitelight1-QRkmJsGkJ7LRq6uH8wmM4g==/base.apk!/lib/armeabi, /system/lib]]] couldn't find "libsqlcipher.so"
    at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
    at java.lang.System.loadLibrary(System.java:1669)
    at net.sqlcipher.database.SQLiteDatabase$1.loadLibraries(SQLiteDatabase.java:213)
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:230)
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:209)
    at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:202)
    at anyhwheresoftware.b4a.objects.sqlcipher.SQLCipher.Initialize(SQLCipher.java:51)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at b4a.sqlitelight1.clsconnection._connect2db(clsconnection.java:149)
    at b4a.sqlitelight1.main$ResumableSub_SetConnection.resume(main.java:9462)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1746)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:6981)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)


    These kind of problem where the reason I was reluctant to move to the new SQLCipher!


    RBS
     
  3. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Managed to go back to the old SQLCipher 1.5 and got it all working again. Needed to deselect and reselect the SQLCipher and Spatialite libraries and refresh
    to get it all back to normal.

    There is an easy way to reproduce the problem I encountered with SQLCipher 1.6:

    1. Download the Spatialite example project:
    https://www.b4x.com/android/forum/threads/spatialite.36296/#post-213030

    2. Download the SQLCipher 1.6 files (with the additional .aar file):
    https://www.b4x.com/android/forum/threads/android-database-encryption-with-sqlcipher-library.14965/

    3. Copy the SQLCipher 1.6 files to the additional library.

    4. Load the example Spatialite project

    5. Add a reference to the SQLCipher 1.6 library

    6. Run the project.

    Although SQCipher is not used in the project at all you will see the error I got (hopefully).


    RBS
     
  4. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    Is there anybody on this forum who is using CQLCipher 1.6 with Spatialite?

    RBS
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice