我已经成功在Eclipse中创建了一个应用程序,并且它适用于Android 4.0及以上版本。现在我想使它也兼容Android 2.3及以上版本。在我的应用程序中,我使用了操作栏,因此我在我的工作区中将android-support-v7-appcompat库项目添加到了我的工作集中。按照http://developer.android.com/tools/support-library/setup.html的说明后,现在我的项目的Android私有库部分下有'android-support--v7-appcompat.jar'和'android-support-v4.jar'。同时,我还将jar文件放在了我的项目的libs文件夹中。
在我的主活动中,我已经导入了:
在AndroidManifest.xml文件中,我已经声明:
此外,对于不同的活动,声明如下:
请帮忙。
在我的主活动中,我已经导入了:
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和themes_base.xml文件包含到我的项目中。同时,通过替换Theme,改变了styles.xml文件。
每次运行应用程序时,我都会遇到崩溃,甚至对于4.0及更高版本的Android也是如此。错误信息:
java.main.NoClassDefFounderError: android.support.v7.appcompat.R$styleable
at android.support.v7.app.ActionBarActivityDelegate.onCreate
请帮忙。