Вопрос

It appears the best way to develop an Android application today is to target android-17 in project.properties along with minSdkVersion "whateversuitsyou" and targetSdkVersion 17 in the manifest.

In this configuration, the standard lint checks will notify about any API calls which are only available in API versions above "whateversuitsyou" and one can use reflection etc to dynamically support the newer features, if any.

However, in this setup, at least without further configuration, it is possible to have style and theme attributes in XML not placed in the appropriate folder, like referring to "Holo" elements in the default resource folder when "whateversuitsyou" is smaller than 11 aka Honeycomb.

It seems apps will not crash if they encounter unknown XML style attributes. LogCat will show an error, like "Style contains key with bad entry".

Not sure whether the whole style is checked upon app startup; if so, it is certainly possible to run the app once on every API version to check for any problems. However, that's not exactly desirable. Besides, styles and themes are not the only version specific resources.

Is there a way to make lint check the resources in general against minSdkVersion and API versio XY for folder *-vXY? Can someone shed some light on this?

Это было полезно?

Решение

Luckily, with the current (updated) configuration, this has become a non-issue, because the development framework handles the situation just the way it should.

Example:

project.properties:

target=android-11

AndroidManifest.xml:

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

You can now use API 8 XML style and theme attributes everywhere and API 11 XML style and theme attributes in -v11 subfolders.

Works with Eclipse Juno Service Release 1, Android SDK Tools 21.1 and Android SDK Platform-tools 16.0.1.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top