Android Question New SQLCipher 4 with Spatialite

RB Smissaert

Well-Known Member
Licensed User
Longtime 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.

B4X:
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
 

RB Smissaert

Well-Known Member
Licensed User
Longtime 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.

B4X:
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

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:

B4X:
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
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime 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:

B4X:
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

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
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime 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

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

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Is there anybody on this forum who is using CQLCipher 1.6 with Spatialite?

RBS

Still trying to solve this problem.
I remember I had a problem with SQLCipher (1.5) and Spatialite and this was very nicely solved by Erel:
https://www.b4x.com/android/forum/threads/use-both-sqlcipher-and-spatialite.94437/#post-597646

I still use the same Spatialite.jar file so lib\armeabi-v7a folder is still not there.
I tried deleting the same folders from android-database-sqlcipher-4.0.0.aar, but that didn't help.
I also tried with the original Spatialite.jar file, so including lib\armeabi-v7a folder, but that didn't help either.

So, still no further.
This is the current error I get with the real B4A project:

java.lang.UnsatisfiedLinkError: No implementation found for void jsqlite.Database.internal_init() (tried Java_jsqlite_Database_internal_1init and Java_jsqlite_Database_internal_1init__)

Any idea what could be the problem here?

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Still trying to solve this problem.
I remember I had a problem with SQLCipher (1.5) and Spatialite and this was very nicely solved by Erel:
https://www.b4x.com/android/forum/threads/use-both-sqlcipher-and-spatialite.94437/#post-597646

I still use the same Spatialite.jar file so lib\armeabi-v7a folder is still not there.
I tried deleting the same folders from android-database-sqlcipher-4.0.0.aar, but that didn't help.
I also tried with the original Spatialite.jar file, so including lib\armeabi-v7a folder, but that didn't help either.

So, still no further.
This is the current error I get with the real B4A project:

java.lang.UnsatisfiedLinkError: No implementation found for void jsqlite.Database.internal_init() (tried Java_jsqlite_Database_internal_1init and Java_jsqlite_Database_internal_1init__)

Any idea what could be the problem here?

RBS

Still not figured this out. I made a simple test project that shows the exact problem.
Attached that project.
SQLCipher 1.6 needs to be added to the project and I think this is how this needs to be done:

1. Backup somewhere the old SQLCipher 1.5 files:
SQLCipher.jar
SQLCipher.xml
SQLCIPHER_LICENCE
sqlcipher_native.jar
These are in the library folder

2.Delete the above files

3. 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/

4. Copy the SQLCipher 1.6 files to the library folder

5. In the attached project set a reference to the new SQLCipher 1.6 and also to the regular SQL library.

Run the project.


RBS
 

Attachments

  • CountryFinder.zip
    309.6 KB · Views: 356
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Still not figured this out. I made a simple test project that shows the exact problem.
Attached that project.
SQLCipher 1.6 needs to be added to the project and I think this is how this needs to be done:

1. Backup somewhere the old SQLCipher 1.5 files:
SQLCipher.jar
SQLCipher.xml
SQLCIPHER_LICENCE
sqlcipher_native.jar
These are in the library folder

2.Delete the above files

3. 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/

4. Copy the SQLCipher 1.6 files to the library folder

5. In the attached project set a reference to the new SQLCipher 1.6 and also to the regular SQL library.

Run the project.


RBS

Correction: SQLCipher (and also Spatialite) library should go to the Additional Libraries folder.
Doesn't make a difference though to the mentioned problem.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Correction: SQLCipher (and also Spatialite) library should go to the Additional Libraries folder.
Doesn't make a difference though to the mentioned problem.

RBS

Still not figured this out.
I re-organised the library folders with a B4A folder etc. with the Additional Libraries folder and moved the SQLCipher and Spatialite files to this folder, but still the same problem.
Is there anybody on this forum who has managed to use the new SQLCipher (1.6) with Spatialite (1.10)?

RBS
 
Upvote 0
Top