Tuesday, August 9, 2011

Fixing up the SQL Lite Exception

You know how I said I would do absolutely no more on Android, how I was going straight IOS today? Well, there is that little matter of the SQL lite exception that's getting thrown up on the marketplace. I really can't let it sit.

The Android Marketplace provides you with a stack trace of the errors that were found, and it was identical for both of them:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kanjisoft.jlpt1.free/com.jlptquiz.app.StartActivity}: android.database.sqlite.SQLiteException: no such table: word_review_schedule: , while compiling: insert into word_review_schedule(_id, last_review_date,next_review_date) values (?, ?, ?)

Some quick googling reveals the solution, at this url

http://www.anddev.org/networking-database-problems-f29/missing-table-in-sqlite-with-specific-version-of-desire-hd-t50364.html

"Missing table in SQLite with specific version of DESIRE HD

Re: Missing table in SQLite with specific version of DESIRE

Post by william104 » Sat Jan 15, 2011 9:48 am
Hi,

I have found a solution thanks to a user of my application.
In the createdatabase function, it must be added:

public void createDataBase() throws IOException{

boolean dbExist = checkDataBase();
SQLiteDatabase db_Read = null; // <<== highlighted

if(dbExist){
//do nothing - database already exist
}else{

//By calling this method and empty database will be created into the default system path
//of your application so we are gonna be able to overwrite that database with our database.
db_Read = this.getReadableDatabase(); // "dbRead =" highlighted
db_Read.close(); // <== highlighted

try {

copyDataBase();

} catch (IOException e) {

throw new Error("Error copying database");

}
}

}


This code looks very familiar, except for the highlighted parts. Apparently, it's a phone issue, according the op:

"This works fine with a lot of devices (Nexus One, Htc Magic, SGS, X10… and even Htc Desire HD v2.2). My application works with all versions of Android (tested on my device (1.6, 2.2, 2.2.1 Htc Magic) and on the emulator (v1,5 until v2.3).

I have just a problem with HTC DESIRE HD v2.2.1 1.72.405.3."

Ok, so, lets try this in our code, and see if it works.


boolean dbExist = checkDataBase();

SQLiteDatabase dbRead = null;

if (dbExist) {
// do nothing - database already exist
} else {

// By calling this method an empty database will be created into
// the default system path
// of your application so we are gonna be able to overwrite that
// database with our database.
dbRead = this.getReadableDatabase();
dbRead.close();

copyDataBase();

}


We both obviously got our code from the same url originally...

So now, let's uninstall one of the free apps and test it.

Ok, it works fine.

Now, we just plow all of these up to the market place. It's really a question of changing the version code in each manifest,
exporting, signing and uploading. But, it's 10 apps at a crack.

Is there a way to export from eclipse project by batch?

SO:

http://stackoverflow.com/questions/6173683/batch-exporting-of-android-apks

"In Eclipse it's not possible to export multiple projects without human intervention.

You can script it by creating ANT build.xml files for all of your projects. The ANT build files allow you to specify the keystore path and key alias that you want to use to sign your APK.

You can create a simple script that goes through all of your projects, and calls the ant release target. This will generate a signed APK file.

That way, you can export all of your apps with a single script.

More information can be found on : http://developer.android.com/guide/developing/building/building-cmdline.html"

There's probably a way to do it with ant. Hmm...well, I will do it next time.

Gotta make sure to click ok on the ok dialog after the export is complete - otherwise it somehow messes with the subsequent dialog and you can save the unsigned apk - I had to restart eclispse.

While I'm waiting for it to build, that reminds me - I want to clean out all those old test projects.

At last, it's completed. The hard part is bouncing in and out of directories. I will really need to build a script.

Ok, the next will be easier, generating the signed apks, since I have a script for that.

Ok, now to upload them.

Ok, that's done. It's a bit tedious, but it's ok. I gave them all a versionCode 5.

And, that's my first in-the field bug-fix completed.





No comments:

Post a Comment