2

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

为了实现动作栏,我使用ActionBarSherlock库。我将sherlock库作为现有项目导入到我的 Eclipse 中。对于sherlock,目标平台是Android v3.2 API 13

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

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的人都遇到过同样的错误??我怎么解决这个问题?

PS我自己的项目清单文件:

<?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>
4

2 回答 2

6

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

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

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

于 2012-02-07T16:15:51.840 回答
1

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

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

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

于 2012-02-07T16:16:11.077 回答