Question

I tried navigation drawer it worked fine in android 4.1 Then I tried in gingerbread,I added supported library appcompat still also I am getting error please help me

01-02 16:48:04.765: E/AndroidRuntime(4688): FATAL EXCEPTION: main
01-02 16:48:04.765: E/AndroidRuntime(4688): java.lang.NoSuchMethodError: com.javatechig.drawer.MainActivity.getActionBar
01-02 16:48:04.765: E/AndroidRuntime(4688):     at com.javatechig.drawer.MainActivity.onCreate(MainActivity.java:40)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.os.Looper.loop(Looper.java:130)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at android.app.ActivityThread.main(ActivityThread.java:3687)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at java.lang.reflect.Method.invokeNative(Native Method)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at java.lang.reflect.Method.invoke(Method.java:507)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
01-02 16:48:04.765: E/AndroidRuntime(4688):     at dalvik.system.NativeStart.main(Native Method)
Was it helpful?

Solution

Use getSupportActionBar(), which is a support library version of getActionBar().

To use all the support methods, you need to extend ActionBarActivity class instead of Activity class.

OTHER TIPS

Try using ActionBar Sherlock instead. Here are some good tutorials for it:http://www.androidbegin.com/tutorial/implementing-actionbarsherlock-side-menu-navigation-with-fragment-tabs-tutorial/

This should help you see the difference between ActionBarCompat and ActionBarSherlock.Difference between ActionBarSherlock and ActionBar Compatibility

This is because they are using Actionbar, action bar supports from 3.0 onwards. In order to support for 2.3 they need to use sherlock action bar. See this: http://actionbarsherlock.com/

The Actionbar is added in android 3.0 so it is not supported in android 2.3 So Use the Go to The Link and download the library and add it to your project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top