0

I try to use the alternative resources / theme selector solution found here to switch to the Holo theme on new devices. The project uses Android 2.1 as project build target.

Hoewever if I put this XML in res/values-v11/styles.xml

<resources>
    <style name="AppTheme" parent="@android:style/Theme.Holo" />
</resources>

Eclipse indicates an error:

Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Holo'. styles.xml /MyApp/res/values-v11

The manifest sets these SDK values:

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

I can only compile this project if I set the Project Build Target to Android 3.0, but then it will not run on older devices.

So this style selector workaround can not be used wit Eclipse ADT. Is this a bug in the Eclipse ADT, should the v11 styles.xml not be ignored by the ADT?


Update: I could use a workaround and set the file content to

<resources>
    <style name="AppTheme" parent="@android:style/Theme" />
</resources>

to activate the default theme.

Community
  • 1
  • 1
mjn
  • 36,362
  • 28
  • 176
  • 378

2 Answers2

2

You can run the App on Android 3.0< if you set android:minSdkVersion to a lower API. So just set the target to API Level 11+ but set minimum SDK to 10<.

Ahmad
  • 69,608
  • 17
  • 111
  • 137
  • see my edit, minSdkVersion is set to 7, but Eclipse only compiles the project if I use the Android 3.0 libraries – mjn Aug 30 '12 at 18:36
  • you **can** compile with the Android 3.0 libraries, as long as you set the minsdkversion to your prefered API – Ahmad Aug 30 '12 at 18:49
  • I accepted your answer (for additional hints on target device problems) – mjn Aug 30 '12 at 19:14
0

Setting the target to 3.0 will not limit it to not run on older devices. That would be minSDKVersion. Setting target to 11+ just allows you to access features that are only in 11+. You just need to be careful not to use any features in the code that use API level 11+. One possible solution for you is to look inot HoloEverywhere which gives you Holo themes for API <11 along with ActionBar Sherlock for ActionBAr stuff that far exceeds the compatibility libraries.

Kaediil
  • 5,465
  • 2
  • 21
  • 20
  • see my edit, minSdkVersion is set to 7, but Eclipse only compiles the project if I use the Android 3.0 libraries – mjn Aug 30 '12 at 18:35
  • Right. So use those libraries is what I am saying. It will still run on the older OS versions as long as you do not use any API calls from the newer API levels. – Kaediil Aug 30 '12 at 18:37
  • If I set the project build target to 3.0, the device selection window does not allow to run the app on a 2.1 device – mjn Aug 30 '12 at 18:39
  • Not sure what the problem is. I have my app set to build for 4.1 and I just ran it without any problems on a 2.1 emulator. My target is 15 and min is 7. – Kaediil Aug 30 '12 at 18:47
  • I am assumin the selection shows an red cross. This is not an indicator weather your App is compatibel or not. Click on the emulator. I will still run – Ahmad Aug 30 '12 at 18:51
  • @Ahmad yes, this was it - the red cross made me halt, it works now, thank you! – mjn Aug 30 '12 at 19:02