Replace deprecated android.support.v4.app.ActionBarDrawerToggle with support.v7 version cause drawer not works on Jelly Bean

Following the answer in this question i have replaced ActionBarDrawerToggle of support v4 library that in latest update(rev 21) has been deprecated with the latest ActionBarDrawerToggle of support-v7 library.

Now the drawer works on Andrid Lollipop Emulator without deprecation warnings but when I test the app on a Jelly Bean real device no drawer and no toggle drawer button is shown.

  • Prevent decompiling android apk
  • How to reduce App (.apk) Size
  • ant jar error: Execute failed: java.io.IOException: Cannot run program…${aapt}": error=2, No such file or directory
  • Android Picasso auto rotates image
  • Unable to play some Youtube videos using YouTube Android Player API
  • Android M FingerprintManager.isHardwareDetected() returns false on a Samsung Galaxy S5
  • What the hell appened with this support library update? How could I fix this issue without downgrade to previous version?

    Here my layout

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <!--  content view -->
    
        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            tools:context=".MainActivity" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/drawer_text" />
        </RelativeLayout>
    
        <!-- nav drawer -->
    
        <ListView
            android:id="@+id/drawer"
            android:layout_width="320dp"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            android:background="#F3F3F4"
            android:choiceMode="singleChoice"
            android:divider="@android:color/transparent"
            android:dividerHeight="0dp" />
    
    </android.support.v4.widget.DrawerLayout>
    

  • Lock Android Device to Run Only One App
  • android : ScrollView vs NestedScrollView
  • How do android “app lock” applications work?
  • Android WebView not loading Mixed Content
  • How can I erase the old data from logcat?
  • Why can I successfully move a file in Linux while it is being written to?
  • One Solution collect form web for “Replace deprecated android.support.v4.app.ActionBarDrawerToggle with support.v7 version cause drawer not works on Jelly Bean”

    1. To get ActionBarDrawerToggle v7 to work properly you need to extends your Activity class from android.support.v7.app.ActionBarActivity
    2. ActionBarActivity v7 must be used with Theme.AppCompat theme from the appcompat-v7:21 support library.
    3. Unless you want to switch from ActionBar to ToolBar, don’t add <item name="windowActionBar">false</item> when extending Theme.AppCompat. Doing so will make your ActionBarActivity have no default ActionBar decor, and getSupportActionBar will return null. You’ll need to provide your own ToolBar and call setSupportActionBar first to make getSupportActionBar work.
    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.