使用ActionBarSherlock库,使用sherlock作为库后出错

时间:2012-02-07 15:51:26

标签: android actionbarsherlock

我自己的项目使用 Android 2.1 API 7

要实施操作栏,我使用ActionBarSherlock库。我将 sherlock 库作为现有项目导入Eclipse。对于 sherlock ,目标平台为 Android v3.2 API 13

然后,我将 sherlock 作为库项目添加到我自己的项目中。然后,我注意到我自己的项目中的R.java文件夹下没有gen/文件,我在eclipse控制台中收到了如下错误:

JakeWharton-ActionBarSherlock-436230d/library/res/values-v11/abs__styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'.

JakeWharton-ActionBarSherlock-436230d/library/res/values-v11/abs__styles.xml:48: error: Error: No resource found that matches the given name: attr 'android:actionBarSize'.

JakeWharton-ActionBarSherlock-436230d/library/res/values-v11/abs__styles.xml:49: error: Error: No resource found that matches the given name: attr 'android:actionBarStyle'.

...

我认为可能是因为 sherlock 应该使用更高版本的API,所以我尝试在 sherlock上将目标平台设置为 4.03 API 15 项目。但它没有帮助。

任何人使用sherlock都遇到了同样的错误?我该如何解决这个问题?

P.S。我自己的项目清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="my.frag.test"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MyActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

2 个答案:

答案 0 :(得分:6)

您的应用和库都需要使用Android 3.2进行编译才能获得适当的支持。

然而,您可以将清单中的minSdkVersion设置为低至'4',以便仍然支持通过Android 1.6。 targetSdkVersion 必须设置为“11”或更高。

查看项目samples/文件夹中的示例,了解如何完成此操作。

答案 1 :(得分:1)

您必须在自己的项目中将构建目标设置为API13。

您的应用处理的最低API级别由您的清单中的android:minSdkVersion定义,而不是构建目标。

将构建目标设置为API13不会使2.1设备上的ActionBar可用,这就是ActionBarSherlock的原因。