Wednesday, September 8, 2010

install Parse Error

Dealt with a rather vague "Parse error" on an Android 2.1 device when trying to install an app (.apk file)

Not a lot of helpful write-ups for this online.

After some debugging and a lot of trial and error, the error appears to be related to the minSdkVersion in the manifest file.

If the manifest file specifies: uses-sdk minsdkversion="8", and the device is an SDK lower than Android 2.2, you will get a parse error on install, even if the app in question is built on a lower SDK.

The process typically used in Eclipse to build a signed apk of a lower SDK compatibility is as follows:
1) CREATE a new Eclipse Android project "foo_" with an older Build Target, generally recommended for compatibility with older devices is API 4 (Android 1.6)
2) IMPORT the "src" and "res" files from "foo" into the "foo_" project, as well as the manifest.xml file, which is needed to specific permissions, activity definitions, etc.
3) EXPORT the apk file using Eclipse and sign the apk (a zip file)

BUT there's a crucial step 2.5, to change uses-sdk minsdkversion="8" to uses-sdk minsdkversion="4" to avoid the parse error. The "8" is assumed when the Build Target is API 8 (Android 2.2).

That's it, now could the Android team come up with a less opaque error msg for this sort of error condition???

Monday, September 6, 2010

Journal Entries continued...

New forms ("intents") for health journal entries: Meals, Exercise, check it out...

Used Android date-picker, which isn't as nice as a calendar selection pop-up but will suffice...

Date conversion from Android (M-d-yyyy) to Keas (MM/dd/yyyy) was a minor but necessary chore:

SimpleDateFormat inputDate = new SimpleDateFormat("M-d-yyyy"); SimpleDateFormat putDate = new SimpleDateFormat("MM/dd/yyyy");
Date _date = null;
try {
_date = inputDate.parse(the_date);
} catch (ParseException e1) {
System.out.println("Error parsing date:"+the_date);
_date = new Date();
the_date = putDate.format(_date); // PUT format

Download signed apk here (try test user name:jim pw:jim)
Download Eclipse project here.