net.sqlcipher.database.SQLiteException

I’m using SQLCipher for android Implementation-Version: v3.5.4-5-g87be8c4
I’m getting below crash reports from play store of customers but stacktrace doesn’t give much information.
net.sqlcipher.database.SQLiteException:
at net.sqlcipher.database.SQLiteCompiledSql.native_compile (SQLiteCompiledSql.java)
at net.sqlcipher.database.SQLiteCompiledSql.compile (SQLiteCompiledSql.java:91)
at net.sqlcipher.database.SQLiteCompiledSql. (SQLiteCompiledSql.java:64)
at net.sqlcipher.database.SQLiteProgram. (SQLiteProgram.java:83)
at net.sqlcipher.database.SQLiteQuery. (SQLiteQuery.java:49)
at net.sqlcipher.database.SQLiteDirectCursorDriver.query (SQLiteDirectCursorDriver.java:42)
at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory (SQLiteDatabase.java:1785)
at net.sqlcipher.database.SQLiteDatabase.rawQuery (SQLiteDatabase.java:1750)
at net.sqlcipher.database.SQLiteDatabase.keyDatabase (SQLiteDatabase.java:2404)
at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal (SQLiteDatabase.java:2333)
at net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:1114)
at net.sqlcipher.database.SQLiteDatabase.openDatabase (SQLiteDatabase.java:1006)
at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase (SQLiteOpenHelper.java:249)
at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase (SQLiteOpenHelper.java:214)

Generally there is message logged like “file is encrypted or not a database” which could lead opening db with wrong key.
I’m looking for what are possible scenarios when actual message is not logged in stacktrace ?

Hi @payas_gupta

It would depend on how your application handles exceptions. SQLCipher for Android will always throw an exception when you attempt to open the database with an invalid password. As an aside, you might consider updating your library, we’ve had several improvements to the library since 3.5.4, which is currently 3.5.9.

Thanks for the reply, I will update libraries. My application doesn’t suppresses exception message and it logs every stacktrace possible. As you can see from above log snippet exception came in sqlcipher library for which actual cause is not present. I’m just curious what could be possible scenario where actual message is not logged.

Hi @payas_gupta

Unfortunately, there are many possible reasons that SQLCipher may not be able to open a file. Providing an invalid password is the most typical scenario, however other issues could arise in which SQLCipher is not able to determine the root cause. For example, if you provide the path to a corrupt database, SQLCipher may not be able to open it.

Not being able to access the database should always cause an exception to occur. Within the SQLCipher for Android test suite we have tests around invalid open arguments and invalid passwords as an example.