I have a class that were extending FragmentActivity and importing android library v4. Now that I want to implement Navigation Drawer in my activity, I'd like to extend ActionBarActivity. And since ActionBarActivity also implements FragmentActivity, I've been told that I could still use fragments in my class with ActionBarActivity.
So I start working with ActionBarActivity, first by importing the v7 library. I copied the file from
C:\Program Files\Android Developer Tools\sdk\extras\android\support\v7
to the libs
folder in my app folder on workspace.
Now my Eclipse detects no errors with my class extending ActionBarActivity. However when I run it, it crashes.
Here's some information found at my LogCat (I wonder if it coulp help at any point):
03-27 16:30:12.113: E/AndroidRuntime(8130): FATAL EXCEPTION: main
03-27 16:30:12.113: E/AndroidRuntime(8130): Process: com.anggrian.readee, PID: 8130
03-27 16:30:12.113: E/AndroidRuntime(8130): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
03-27 16:30:12.113: E/AndroidRuntime(8130): at com.anggrian.readee.MainActivity.onCreate(MainActivity.java:37)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.Activity.performCreate(Activity.java:5231)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2265)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.ActivityThread.access$800(ActivityThread.java:145)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.os.Handler.dispatchMessage(Handler.java:102)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.os.Looper.loop(Looper.java:136)
03-27 16:30:12.113: E/AndroidRuntime(8130): at android.app.ActivityThread.main(ActivityThread.java:5081)
03-27 16:30:12.113: E/AndroidRuntime(8130): at java.lang.reflect.Method.invokeNative(Native Method)
03-27 16:30:12.113: E/AndroidRuntime(8130): at java.lang.reflect.Method.invoke(Method.java:515)
03-27 16:30:12.113: E/AndroidRuntime(8130): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
03-27 16:30:12.113: E/AndroidRuntime(8130): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-27 16:30:12.113: E/AndroidRuntime(8130): at dalvik.system.NativeStart.main(Native Method)
I wonder if I could get any help, thanks!
@Raghunandan here's my styles.xml:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" 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="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<!-- MY OWN THEME -->
<style name="DarkGreyTheme" parent="@android:style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/DarkGreyActionBar</item>
</style>
<style name="DarkGreyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#b6b6b6</item>
</style>
<!-- MY OWN THEME -->
<style name="OrangeTheme" parent="@android:style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/OrangeActionBar</item>
</style>
<style name="OrangeActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#ff6400</item>
</style>
</resources>
the AppTheme is not used in AndroidManifest.xml so just ignore them. I used to use @android:style/Theme.Holo.Light in my custom themes but since I already extending ActionBarActivity in my main class, LogCat indicates I need to use AppCompat Theme.