Android Question Can I update to a newer version of SQLCipher?

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Currently using SQLCipher 1.6, which uses SQLite version 3.25.2 and was compiled 25/Sep/2018.
According the .xml file (SQLCipher.xml) SQLCipher depends on the .aar file android-database-sqlcipher-4.0.0.aar.
Now I have newer versions of the SQLCipher .aar file, that is android-database-sqlcipher-4.4.3.aar and android-database-sqlcipher-4.5.1.aar.
I tried changing the .xml file and make it depend on 4.5.1 (this is at the end of the .xml file) and it compiled fine, but there was a run-time error
to do with SQLCipher.

Is it possible to use a later version of SQLCipher by altering the .jar and/or .xml files?
Is there any other way to update the SQLCipher version?
According to Nick Parker of Zetetic the .aar file is self contained, not needing any other files, but not sure how to organise that.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Which error did you get?
This is the full, unfiltered error message on starting up the app:

Logger connected to: RFCW1040KQA
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
clsconnection$ResumableSub_Connect2DBresume (java line: 696)
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/sqlcipher/database/SQLiteDatabase;
at anyhwheresoftware.b4a.objects.sqlcipher.SQLCipher.Initialize(SQLCipher.java:51)
at b4a.exampleljjll.clsconnection$ResumableSub_Connect2DB.resume(clsconnection.java:696)
at b4a.exampleljjll.clsconnection._connect2db(clsconnection.java:533)
at b4a.exampleljjll.b4xmainpage$ResumableSub_SetConnection.resume(b4xmainpage.java:40199)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:215)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:230)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8893)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.ClassNotFoundException: net.sqlcipher.database.SQLiteDatabase
... 16 more
Starter, LogError, strErrorMsg: java.lang.Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lnet/sqlcipher/database/SQLiteDatabase;

This is after just changing the .xml (and nil else) having this at the end:

<version>1.6</version>
<comment></comment>
<dependsOn>android-database-sqlcipher-4.5.1.aar</dependsOn>
</root>

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I guess that the packages have changed and it breaks the wrapper. If you are adventurous you can create a Java project in Eclipse with SQLCipher wrapper code: https://github.com/AnywhereSoftware...software/b4a/objects/sqlcipher/SQLCipher.java and the extracted classes from the aar file, and fix the wrapper.
I never coded in Java or used Eclipse, so that won't be simple, but may give that a try.

I found a more recent .aar file and also .jar file at:
I tried the same with this .aar, so changing the .xml file to point to that .aar file,
but had the same problem.
Not ever sure if the .jar file found (sqlcipher-android-4.5.6-sources.jar) should replace
the current .jar file, SQLCipher.jar.

Thanks in any case for the tip.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I guess that the packages have changed and it breaks the wrapper. If you are adventurous you can create a Java project in Eclipse with SQLCipher wrapper code: https://github.com/AnywhereSoftware...software/b4a/objects/sqlcipher/SQLCipher.java and the extracted classes from the aar file, and fix the wrapper.
I can see that in the SQLCipher Java wrapper code this is a problem:

B4X:
@ShortName("SQLCipher")
@Version(1.60f)
@DependsOn(values={"android-database-sqlcipher-4.0.0.aar"})

If I use the most recent SQLCipher .aar file then it should be:

B4X:
@DependsOn(values={"sqlcipher-android-4.5.6.aar"})

No idea yet though how to compile that.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
The annotations (@...) are used by the tool that creates the XML file. You don't to change it as you modified the XML directly.
OK, thanks.
Am I right that the .xml file should remain just the same as old original .xml, apart from this bit at the bottom of the .xml:

<version>1.6</version>
<comment/>
<dependsOn>android-database-sqlcipher-4.0.0.aar</dependsOn>
</root>

?

I think with the latest .aar the version is called 1.6f.
Should I change that as well?

I take it I need to add a new .jar file?
With version 4.5.6 that .jar file is called:
sqlcipher-android-4.5.6-sources.jar

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
OK, thanks.
Am I right that the .xml file should remain just the same as old original .xml, apart from this bit at the bottom of the .xml:

<version>1.6</version>
<comment/>
<dependsOn>android-database-sqlcipher-4.0.0.aar</dependsOn>
</root>

?

I think with the latest .aar the version is called 1.6f.
Should I change that as well?

I take it I need to add a new .jar file?
With version 4.5.6 that .jar file is called:
sqlcipher-android-4.5.6-sources.jar

RBS
Version in the .xml should remain at: 1.6 otherwise it won't compile.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I guess that the packages have changed and it breaks the wrapper. If you are adventurous you can create a Java project in Eclipse with SQLCipher wrapper code: https://github.com/AnywhereSoftware...software/b4a/objects/sqlcipher/SQLCipher.java and the extracted classes from the aar file, and fix the wrapper.
Have installed Eclipse (Windows 10) and started a project and added SQLCipher.java and all the 18 classes (java files) from sqlcipher-android-4.5.6.aar.
Just a simple question: After adding all these 19 classes how do I save the Eclipse project?
Can't see anything in the IDE that looks like it will do that.

RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Have installed Eclipse (Windows 10) and started a project and added SQLCipher.java and all the 18 classes (java files) from sqlcipher-android-4.5.6.aar.
Just a simple question: After adding all these 19 classes how do I save the Eclipse project?
Can't see anything in the IDE that looks like it will do that.

RBS
Not sure how it got saved, but I closed Eclipse, no warning to save first, restarted Eclipse and all the classes were still there, so that is OK.
Having all the classes, including SQLCipher in Eclipse, what should be done next to fix that wrapper?
I am not sure what that wrapper actually is.

RBS
 
Upvote 0
Top