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???

No comments:

Post a Comment