[TIMOB-8622] Android: Random Android Installation bugs when building to device - sqlite realted
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-03-18T20:34:52.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | Release 3.0.2, 2013 Sprint 06 Core, 2013 Sprint 06 |
Components | Android |
Labels | SupportTeam, core, qe-testadded |
Reporter | Ketan Majmudar |
Assignee | Ingo Muschenetz |
Created | 2012-04-05T06:41:09.000+0000 |
Updated | 2013-10-04T11:25:18.000+0000 |
Description
Problem Description
When building to android I get regular occasional errors when building to the device which fails to initialise the app.Actual Results
Here is the DDMS error:
04-05 15:36:30.609: E/TiApplication(32009): (main) [348,985] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file; Titanium 2.0.0,2012/03/30 10:33,b091bae
04-05 15:36:30.609: E/TiApplication(32009): java.lang.RuntimeException: Unable to create application uk.co.spiritquest.sfl11b1.ScifilondonApplication: android.database.sqlite.SQLiteException: unable to open database file
04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3812)
04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.access$2200(ActivityThread.java:132)
04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1082)
04-05 15:36:30.609: E/TiApplication(32009): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:36:30.609: E/TiApplication(32009): at android.os.Looper.loop(Looper.java:150)
04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.main(ActivityThread.java:4277)
04-05 15:36:30.609: E/TiApplication(32009): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:36:30.609: E/TiApplication(32009): at java.lang.reflect.Method.invoke(Method.java:507)
04-05 15:36:30.609: E/TiApplication(32009): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-05 15:36:30.609: E/TiApplication(32009): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-05 15:36:30.609: E/TiApplication(32009): at dalvik.system.NativeStart.main(Native Method)
04-05 15:36:30.609: E/TiApplication(32009): Caused by: android.database.sqlite.SQLiteException: unable to open database file
04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1956)
04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:902)
04-05 15:36:30.609: E/TiApplication(32009): at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:208)
04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.util.TiDatabaseHelper.getPlatformParam(TiDatabaseHelper.java:73)
04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.util.TiPlatformHelper.initialize(TiPlatformHelper.java:69)
04-05 15:36:30.609: E/TiApplication(32009): at org.appcelerator.titanium.TiApplication.postAppInfo(TiApplication.java:349)
04-05 15:36:30.609: E/TiApplication(32009): at uk.co.spiritquest.sfl11b1.ScifilondonApplication.onCreate(ScifilondonApplication.java:34)
04-05 15:36:30.609: E/TiApplication(32009): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:984)
04-05 15:36:30.609: E/TiApplication(32009): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3809)
04-05 15:36:30.609: E/TiApplication(32009): ... 10 more
Expected results
the DB working fineTest Case
1. Create New mobile project 2. Add this code:
var win = Ti.UI.createWindow();
var l = Titanium.UI.createLabel({
text:'See Log for output',
top:10,
left:10,
height:'auto',
width:'auto'
});
win.add(l);
var b1 = Titanium.UI.createButton({
title:'DB in 2nd Context',
width:200,
height:40,
top:40
});
win.add(b1);
b1.addEventListener('click', function()
{
var win1 = Titanium.UI.createWindow({
url:'database_2.js',
height:30,
width:280,
borderRadius:10,
bottom:80,
backgroundColor:'#333'
});
var l1 = Titanium.UI.createLabel({
text:'2nd context test - see log.',
color:'#fff',
font:{fontSize:14},
width:'auto',
height:'auto'
});
win1.add(l1);
win1.open();
});
var b2 = Titanium.UI.createButton({
title:'Pre-packaged DB',
width:200,
height:40,
top:100
});
win.add(b2);
b2.addEventListener('click', function()
{
var win2 = Titanium.UI.createWindow({
url:'database_3.js',
height:30,
width:280,
borderRadius:10,
bottom:140,
backgroundColor:'#333'
});
var l2= Titanium.UI.createLabel({
text:'Pre-packaged Db - see log.',
color:'#fff',
font:{fontSize:14},
width:'auto',
height:'auto'
});
win2.add(l2);
win2.open();
});
var l3 = Titanium.UI.createLabel({
text:'unicode placeholder',
width:300,
height:40,
top:190
});
win.add(l3);
if (Ti.Platform.osname !== 'android')
{
win.add(l3);
var b3 = Titanium.UI.createButton({
title:'Check DB FullPath',
width:200,
height:40,
top:150
});
b3.addEventListener('click', function()
{
var path = db.file;
alert("mysql.db fullpath : \n \nType :" + path +"\n\nFullPath: "+path.nativePath);
});
win.add(b3);
}
var db = Titanium.Database.open('mydb');
db.execute('CREATE TABLE IF NOT EXISTS DATABASETEST (ID INTEGER, NAME TEXT)');
db.execute('DELETE FROM DATABASETEST');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',1,'Name 1');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',2,'Name 2');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',3,'Name 3');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',4,'Name 4');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)', 5, '\u2070 \u00B9 \u00B2 \u00B3 \u2074 \u2075 \u2076 \u2077 \u2078 \u2079');
var updateName = 'I was updated';
var updateId = 4;
db.execute('UPDATE DATABASETEST SET NAME = ? WHERE ID = ?', updateName, updateId);
db.execute('UPDATE DATABASETEST SET NAME = "I was updated too" WHERE ID = 2');
db.execute('DELETE FROM DATABASETEST WHERE ID = ?',1);
Titanium.API.info('JUST INSERTED, rowsAffected = ' + db.rowsAffected);
Titanium.API.info('JUST INSERTED, lastInsertRowId = ' + db.lastInsertRowId);
var rows = db.execute('SELECT * FROM DATABASETEST');
Titanium.API.info('ROW COUNT = ' + rows.getRowCount());
Titanium.API.info('ROW COUNT = ' + rows.getRowCount());
Titanium.API.info('ROW COUNT = ' + rows.getRowCount());
while (rows.isValidRow())
{
Titanium.API.info('ID: ' + rows.field(0) + ' NAME: ' + rows.fieldByName('name') + ' COLUMN NAME ' + rows.fieldName(0));
if (rows.field(0)==5)
{
l3.text = rows.fieldByName('name');
}
rows.next();
}
rows.close();
db.close(); // close db when you're done to save resources
win.open();
I get this as well in my properly compiled app that is running correct for 95% of users. I see the following in my crash reports (from the android dev console website): java.lang.RuntimeException: Unable to create application com.apsquared.tvfoodmaps.TvfoodmapsApplication: android.database.sqlite.SQLiteException: unable to open database file at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4501) at android.app.ActivityThread.access$3000(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2181) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:144) at android.app.ActivityThread.main(ActivityThread.java:4937) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) Caused by: android.database.sqlite.SQLiteException: unable to open database file at android.database.sqlite.SQLiteDatabase.dbopen(Native Method) at android.database.sqlite.SQLiteDatabase.
This is happening on recent CI build of 2.1.1 - unfortunately I cant tell from the android reports what devices it is happening on.
Can confirm that we have this same error on an HTC ChaCha , and the funny thing is that we arent using SQLLite
This looks identical to this: http://stackoverflow.com/questions/3563728/random-exception-android-database-sqlite-sqliteexception-unable-to-open-databas
PR: https://github.com/appcelerator/titanium_mobile/pull/3618
Tested with: SDK:3.0.2.v20130201161712 Studio: 3.0.2.201301281948 Device: iPhone3GS(v 5.0.1), iPhone5(v 6.0)
Reopen to modify labels and add new subtask
Ticket was reopened to add subtasks and change labels, but wasn't closaed afterwards.