SQLiteException not an error at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)

1k views Asked by At

I am facing an issue while running the junit test cases in android studio. The issue is very strange as when I run the test cases for the first time in the phone it works perfectly fine, but if the app is already installed and when I run the test cases I get following error:-

net.sqlcipher.database.SQLiteException: not an error
at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1942)
at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875)
at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:907)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:132)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:99)

All the sqlcipher dependencies are correctly configured.

2

There are 2 answers

0
bakriOnFire On BEST ANSWER

I found the solution for this issue. When I saw in the logs, I found that the actual issue was

Unable to copy icudt46l.zip file

It was happening because i was not calling the loadlibs of SQLiteCipher inside the test suites.

So I added the following line in setup() method of my test class

SQLiteDatabase.loadLibs(getContext(), getContext().getFilesDir());
0
sbrandler123 On

The database might not be properly closed after you run your app the first time. Try using Close method from SQLiteConnection class:

db.Close()