user79758
user79758

Reputation:

Can I set API level X attributes in my manifest when my minSdkVersion is less than X?

I'm working on an Android application where I'd like to have the largeHeap and hardwareAccelerated flags on. However, it also needs to support Android 2.3.

My AndroidManifest.xml looks like the following:

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

<application
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:hardwareAccelerated="true"
        android:largeHeap="true"
        >

However, Eclipse refuses to build the project, saying:

error: No resource identifier found for attribute 'hardwareAccelerated' in package 'android'
error: No resource identifier found for attribute 'largeHeap' in package 'android'

Raising the targetSdkVersion to 11, where such flags were introduced, does not solve the problem.

Is it possible to support Android 2.3 and still set these flags?

Upvotes: 7

Views: 5601

Answers (1)

thaussma
thaussma

Reputation: 9886

Yes you can add the XML attributes but you have to build with the required sdk level for those attributes. Older plattforms will just ignore those attributes. To do so change the Project Build Target to 11 in the project specific Android settings in Eclipse.

But pay attention, if you start building your project with sdk level 11 you could easily slip in code that does not execute on devices with level <11.

See Backward Compatiblity for an similar explanation on how to enable the installLocation attribute (introduced in level 8) and still build for sdk level less than 8.

Upvotes: 11

Related Questions