我已经在 Eclipse 中成功创建了一个应用程序,它适用于 android 4.0 及更高版本。现在我想让它也兼容 android 2.3 及更高版本。在我的应用程序中,我使用了操作栏,因此我在工作区的工作集中添加了 android-support-v7-appcompat 库项目。遵循http://developer.android.com/tools/support-library/setup.html说明后,现在我有 'android-support--v7-appcompat.jar' 和 'android-support-v4.jar'under我的项目 Android 私有库部分。我的项目的 libs 文件夹下还有 jar 文件。
在我的主要活动中,我导入了:
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
在 AndroidManifest.xml 文件中,我声明:
<application android:allowBackup="true"
android:theme="@style/Theme.AppCompat"
此外,对于不同的活动,声明为:
<activity android:
android:uiOptions="splitActionBarWhenNarrow"
以前我的 AndroidManifest.xml 是这样的:
<application android:allowBackup="true"
android:theme="@style/<theme>"
res>values 文件夹下的 styles.xml 是这样的:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="<base>" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="<theme>" parent="<base>">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
用过的
<style name="<base>" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
在 values-v11 文件夹和
<style name="<base>" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 11 theme customizations can go here. -->
</style>
在 values-v14 文件夹中。
我现在已将库项目中的所有 styles_base.xml 和 theme_base.xml 文件包含到我的项目中。还通过将 Theme 替换为 .
每次运行该应用程序时,我都会面临崩溃,现在即使是 4.0 及更高版本的 android 版本。消息:
java.main.NoClassDefFounderError: android.support.v7.appcompat.R$styleable
at android.support.v7.app.ActionBarActivityDelegate.onCreate
请帮忙。