Question

Is it possible to use progressive enhancement when building Android apk's. I'd like to build an app which can be used on SDK 8 + (gingerbread is the dominant android version) and when possible add features from newer version.

I know I can get the SDK version with SDK_INT to do something conditional, however when I use features introduced in later versions, eclipse won't let me build saying I need to increase the min SDK level.
Maybe my web development background is what's causing my thinking this to be possible, it may just be fundamentally impossible, do popular apps have different versions for different SDKS (like min8-max10,min11-max15)? Is progressive enhancement in Android Java code possible?

Was it helpful?

Solution

check if the build fails because of Lint errors, if so, and you're certain that a specific method won't be called on non-supported devices, add an annotation to that method with the min api level it can be called on as such:

@TargetApi(14)
public void useSomeNewApis() {
   ...
}

Or, if you're using eclipse, you can hover on the error line, and choose add @TargetApi(14) to useSomeNewApis

OTHER TIPS

Something like:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>

should be enough. But when program hit code from newer API than is on device then it will crash.

You need to make sure you are using the correct version of android. If you want to use a feature available in API 15 you have to build it in that API.

So if the feature you want to use requires API 15 make sure that in your project properties you have Project Build Target set to that API.

Right click on the your project and go to Properties. Select the Android section and make sure the correct API is checked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top