Droid Learner
Droid Learner

Reputation: 65

working on 4.0.3 and 4.1 but Error on 2.1,2.2 and 2.3 - Sherlock Action Bar

I was following one SIMPLE tutorial of Sherlock Action Bar. I followed each and every step. The problem is I'm getting error on versions 2.1 to 2.3 and working fine on 4.0 to 4.1.
I'm using Android SDK tools 20.0.3 And Eclipse version 4.2.0

setContentView(R.layout.activity_main);

In above code it says R cannot be resolved to a variable. and some more errors are as follows:

 [2012-09-04 22:18:21 - Action Bar demo] C:\Users\Karthick\Desktop\Project libs\JakeWharton-ActionBarSherlock-88fc341\library\res\values-v14\abs__styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.
    [2012-09-04 22:18:21 - Action Bar demo] C:\Users\Karthick\Desktop\Project libs\JakeWharton-ActionBarSherlock-88fc341\library\res\values-v14\abs__styles.xml:6: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar.Solid'.
    [2012-09-04 22:18:21 - Action Bar demo] C:\Users\Karthick\Desktop\Project libs\JakeWharton-ActionBarSherlock-88fc341\library\res\values-v14\abs__styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar'.
    [2012-09-04 22:18:21 - Action Bar demo] C:\Users\Karthick\Desktop\Project libs\JakeWharton-ActionBarSherlock-88fc341\library\res\values-v14\abs__styles.xml:10: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.Solid'.

For better understanding, here are some images:

enter image description here

enter image description here

My manifest file is:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.action.bar"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Sherlock" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Google"></activity>
</application>  

Somebody assist me in fixing these errors in Android 2.3

The same code is working fine in Android 4.0.3

Upvotes: 5

Views: 6588

Answers (2)

Paresh Mayani
Paresh Mayani

Reputation: 128428

The problem is I'm getting error on versions 2.1 to 2.3 and working fine on 4.0 to 4.1.

=> As you have mentioned this is working fine in 4.0 and 4.1 but not in 2.x version, i am sure you forgot include compatible ActionBarSherlock theme in your style.xml:

If you haven't included styles.xml with below values, then do it:

<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar"/>

As you have mentioned above about values-v11 and values-v14 for styles.xml, you can create styles.xml in both the folder with below values:

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"/>

Upvotes: 5

Kaediil
Kaediil

Reputation: 5535

I am a little confused when I look at your screen shot. First, your project should be using Android 4.0.3, not 2.3 in the Android libraries. You already cover 2.3 with the minSDKVersion line in your manifest. Second I can't quite tell, but I assume that in the properties for your project, you made your main project be dependent upon the ActionBarSherlock library?

Upvotes: 0

Related Questions