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

I am working on an Android application where I would like to enable the largeHeap and hardwareAccelerated flags. However, it should also support Android 2.3.

My AndroidManifest.xml is as follows:

<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 targetSdkVersion to 11 , where such flags were introduced, does not solve the problem.

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

+7
source share
1 answer

Yes, you can add XML attributes, but you need to build with the required sdk level for these attributes. Older plattforms simply ignore these attributes. To do this, change the Project Build Target value to 11 in the Android settings for Android in Eclipse.

But note that if you start building your project using the sdk 11 level, you can easily skip code that does not run on devices with a level of <11.

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

+11
source

All Articles