Unable to integrate SQLCipher with ORMLite 4.48

Hi,

I want to implement encryption in my android app, I checked the docs it contains code compatible with SQLite, but my app is using ORMLite 4.48. Kindly help me.

Thanks,
Lalit Vasan

Hello @Lalit_Vasan

Since you are targeting the Android platform, you may wish to consider SQLCipher for Android. Here is a tutorial for integrating the library within an application. Please keep in mind that it does not include an ORM, rather it is based on the android.database.sqlite package found in the Android SDK.

Hi @developernotes

Yes, I already have gone through this tutorial. Actually currently my app is using ORMLite for SQL related work. Now I have to integrate SQLCipher for encryption and Kindly suggest me a way that I can implement SQLCipher with ORMLite 4.48.

Thanks,
Lalit

There does not appear to be any official support by the ORMLite maintainers for using either SQLCipher for Android or Google’s support database API.

This Stack Overflow answer links to materials written by a third party to integrate SQLCipher for Android with ORMLite 4.43. Perhaps you can adapt the technique to work for 4.48.

Hi @developernotes,

I have integrated SQLCiper with ORMLite and i am facing some issues.

Gradle dependencies used:-
compile ‘com.j256.ormlite.cipher:ormlite-sqlcipher:1.1@aar’
compile ‘com.j256.ormlite:ormlite-core:5.1’
compile ‘com.j256.ormlite:ormlite-android:5.1’
compile ‘net.zetetic:android-database-sqlcipher:3.5.9@aar’

Crash:-
java.lang.NoSuchMethodError: No static method extractTableName(Ljava/lang/Class;)Ljava/lang/String; in class Lcom/j256/ormlite/table/DatabaseTableConfig; or its super classes (declaration of ‘com.j256.ormlite.table.DatabaseTableConfig’ appears in /data/app/com.cmo.compliance.android-1/base.apk:classes34.dex)
at com.j256.ormlite.cipher.android.DatabaseTableConfigUtil.fromClass(DatabaseTableConfigUtil.java:64)
at com.j256.ormlite.cipher.db.SqliteAndroidDatabaseType.extractDatabaseTableConfig(SqliteAndroidDatabaseType.java:107)
at com.j256.ormlite.dao.DaoManager.createDao(DaoManager.java:67)
at com.j256.ormlite.table.TableUtils.createTable(TableUtils.java:54)
at com.cmo.compliance.android.DBHelper.onCreate(DBHelper.java:66)
at com.j256.ormlite.cipher.android.apptools.OrmLiteSqliteOpenHelper.onCreate(OrmLiteSqliteOpenHelper.java:183)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:171)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:129)
at com.cmo.compliance.android.HelperFactory.setHelper(HelperFactory.java:20)
at com.cmo.compliance.android.CmoApplication.onCreate(CmoApplication.java:98)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)

Hi @developernotes

have integrated SQLCiper with ORMLite and I am facing some issues.

Gradle dependencies used:-
compile ‘com.j256.ormlite.cipher:ormlite-sqlcipher:1.1@aar’
compile ‘com.j256.ormlite:ormlite-core:4.48’
compile ‘com.j256.ormlite:ormlite-android:4.48’
compile ‘net.zetetic:android-database-sqlcipher:3.4.0@aar’

Crash:-
java.lang.NoSuchMethodError: No interface method getSpecialConnection(Ljava/lang/String;)Lcom/j256/ormlite/support/DatabaseConnection; in class Lcom/j256/ormlite/support/ConnectionSource; or its super classes (declaration of ‘com.j256.ormlite.support.ConnectionSource’ appears in /data/app/com.cmo.compliance.android-1/base.apk:classes35.dex)
at com.j256.ormlite.cipher.android.apptools.OrmLiteSqliteOpenHelper.onCreate(OrmLiteSqliteOpenHelper.java:171)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:171)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:129)
at com.cmo.compliance.android.HelperFactory.setHelper(HelperFactory.java:20)
at com.cmo.compliance.android.CmoApplication.onCreate(CmoApplication.java:98)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Hi @Lalit_Vasan

Both of your stack traces appear to be related to ORMLite, not SQLCipher for Android. You may wish to reach out to the ORMLite folks here for further assistance.