14

To enable hardware acceleration in an Android 3.0+ app I can do this:

<application android:hardwareAccelerated="true" ... />

But the app won't build with that attribute present if I target an OS version pre-11. Is there a way to enable hardware acceleration in an app that targets both Honeycomb and prior, or is hardware acceleration only available for those creating apps that only work on 3.0+?

I had a look for a method on Activity but I don't see one.

2 Answers 2

20

Try to set build target to the 3.0 version, but set minsdkversion to the oldest version you want to support. It should at least allow you to build, but will not enable HW-acceleration on the older versions.

From the documentation:

Starting from Android 3.0, a hardware-accelerated OpenGL renderer is available to applications, to improve performance for many common 2D graphics operations. When the hardware-accelerated renderer is enabled, most operations in Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This results in smoother animations, smoother scrolling, and improved responsiveness overall, even for applications that do not explicitly make use the framework's OpenGL libraries.

Have not tested the 3.0 API yet myself, but the documentation seems to say this should be supported...

<manifest ... >
    <uses-sdk android:minSdkVersion="4" 
          android:targetSdkVersion="11" />
    <application ... >
    ...
    <application>
</manifest>

(cut from Optimizing Apps for Android 3.0

4
  • Doesn't work unfortunately - I have minSdkVersion="5" and targetSdkVersion="11" but it will not build with the hardware acceleration attribute in the manifest. I'm hoping there's a way to do it at runtime, perhaps through a method I can call via reflection, though I cannot see one.
    – Ollie C
    Mar 1, 2011 at 19:16
  • 3
    Installing 3.0 API myself now. Did you specify target version both places? manifest (as I just updated in my answer), as well as Eclipse project settings (if using Eclipse)?
    – Arve
    Mar 1, 2011 at 19:28
  • I had the manifest set up with minSdkVersion="5" and targetSdkVersion"11" but you are of course right that the project also needed building against the platform 11 library. Thx.
    – Ollie C
    Mar 7, 2011 at 16:22
  • 2
    change it in the project.properties file as well
    – borislemke
    May 14, 2012 at 21:14
9

You can leave the min/targetSdkVersion as-is in your manifest. I have mine at 3 & 8. What you need to do is change the SDK you're compiling against. In Eclipse, go to Project Properties > Android and choose a Project API Target with an API Level of 11 or above (e.g., "Android 3.0").

1
  • this works. Just the compiling version should be above 11 and do a clean up of the project to solve the error
    – Yogamurthy
    Apr 11, 2015 at 16:56

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.