Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19206] Android: Encrypted Database: Not being able to read installed database

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-11-05T02:15:06.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.2.0
ComponentsAndroid
Labelsdatabase, module_database, qe-manualtest, qe-testadded, sqlite
ReporterMarco Cota
AssigneeAshraf Abu
Created2015-06-19T23:52:36.000+0000
Updated2016-01-19T22:42:48.000+0000

Description

Issue

When working on Android and trying to install a pre-populated database Encrypted database module and open is throwing the following error:
[INFO]  Database: sqlite returned: error code = 26, msg = file is encrypted or is not a database
[ERROR] Database: CREATE TABLE android_metadata failed
[ERROR] Database: Failed to setLocale() when constructing, closing the database
[ERROR] Database: net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
[ERROR] Database: 	at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)
[ERROR] Database: 	at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2102)
[ERROR] Database: 	at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1968)
[ERROR] Database: 	at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:901)
[ERROR] Database: 	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:929)
[ERROR] Database: 	at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:936)
[ERROR] Database: 	at appcelerator.encrypteddatabase.EncrypteddatabaseModule.open(EncrypteddatabaseModule.java:83)
[ERROR] Database: 	at appcelerator.encrypteddatabase.EncrypteddatabaseModule.install(EncrypteddatabaseModule.java:145)
[ERROR] Database: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] Database: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[ERROR] Database: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908)
[ERROR] Database: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131)
[ERROR] Database: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)
[ERROR] Database: 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:101)
[ERROR] Database: 	at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:424)
[ERROR] Database: 	at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] Database: 	at android.os.Looper.loop(Looper.java:137)
[ERROR] Database: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
[WARN]  W/System.err: java.lang.NullPointerException
[WARN]  W/System.err: 	at appcelerator.encrypteddatabase.EncrypteddatabaseModule.open(EncrypteddatabaseModule.java:90)
[WARN]  W/System.err: 	at appcelerator.encrypteddatabase.EncrypteddatabaseModule.install(EncrypteddatabaseModule.java:145)
[WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
[WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:908)
[WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1131)
[WARN]  W/System.err: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)
[WARN]  W/System.err: 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:101)
[WARN]  W/System.err: 	at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:424)
[WARN]  W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:95)
[WARN]  W/System.err: 	at android.os.Looper.loop(Looper.java:137)
[WARN]  W/System.err: 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
[ERROR] TiExceptionHandler: (main) [947,947] ----- Titanium Javascript Runtime Error -----
[ERROR] TiExceptionHandler: (main) [0,947] - In ti:/invoker.js:101,19
[ERROR] TiExceptionHandler: (main) [0,947] - Message: Uncaught Error: Java Exception occurred
[ERROR] TiExceptionHandler: (main) [1,948] - Source: 		return delegate.apply(invoker.__thisObj__, args);
[ERROR] V8Exception: Exception occurred at ti:/invoker.js:101: Uncaught Error: Java Exception occurred
During research i found some similar issues in native development: http://stackoverflow.com/questions/13537073/android-sqlcipher-pragma-problems http://stackoverflow.com/questions/20373066/sqlcipher-create-table-android-metadata-failed

Steps to reproduce

1. Run alloySample (attached alloySample.zip) Expected Result The database will install and run correctly Actual Result We receive the following error "sqlite returned: error code = 26, msg = file is encrypted or is not a database"

Attachments

FileDateSize
alloySample.zip2015-06-19T23:52:32.000+00008550623
testdbencrypt.sqlite2015-10-29T07:28:19.000+00002048

Comments

  1. Ingo Muschenetz 2015-07-08

    [~cng] Can you please schedule this for an upcoming sprint?
  2. Chee Kiat Ng 2015-07-10

    [~hpham], can you please take a look at this? Thanks.
  3. Chee Kiat Ng 2015-08-05

  4. Lokesh Choudhary 2016-01-19

JSON Source