net.sqlcipher.database.SQLiteException: not authorized: , while compiling: select count(*) from sqlite_master


#1

SQLCipher version - 3.5.9, Android OS - Android 6.0

  • We are already loading the library using - SQLiteDatabase.loadLibs(context); at the start of the app before calling any database related api.

  • Database password is also plain text without any encryption.

While calling getWritableDatabase(getPassword()), sqlcipher is throwing following exception -

net.sqlcipher.database.SQLiteException: not authorized: , while compiling: select count(*) from sqlite_master;
                                                              at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
                                                              at net.sqlcipher.database.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
                                                              at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
                                                              at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:89)
                                                              at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:48)
                                                              at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:60)
                                                              at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1867)
                                                              at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1785)
                                                              at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SQLiteDatabase.java:2486)
                                                              at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2415)
                                                              at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1149)
                                                              at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:1212)
                                                              at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:162)
                                                              at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:129)
                                                              at com.cropin.smartfarm.core.db.DBHelper.getDb(DBHelper.java:93)

#2

Hello @CropIn_Developer - You will receive a not authorized error if you are using SQLCipher Commercial Edition and your license key is invalid or has expired (i.e. if you are using a trial version and the trial period is over).