1

I have a toolbar with menu icon and I have attached a click on the menu which opens the left drawer.

I have tested on multiple devices without any issues. But on Play Store I see crashes due to this. The effected devices on Redmi Note 4 and 5.

Complete log below.

java.lang.IllegalArgumentException: 
at android.support.v4.widget.DrawerLayout.openDrawer (DrawerLayout.java:1618)
  at gamesmint.com.jsone.NewLayoutActivity$1.onClick (NewLayoutActivity.java:199)
  at android.view.View.performClick (View.java:6304)
  at android.view.View$PerformClick.run (View.java:24803)
  at android.os.Handler.handleCallback (Handler.java:790)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6600)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:518)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:821)
Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126
SPS
  • 147
  • 11
  • What version of Android is Redmi Note 4 and 5 running? Do you have more code you can show us? Can you show us the line of code #199 in `NewLayoutActivity` and the surrounding code? – James Aug 06 '18 at 03:21
  • The Android version is 7 and 8.1. The code Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false);toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // perform whatever you want on back arrow click mDrawerLayout.openDrawer(Gravity.LEFT); } }); – SPS Aug 06 '18 at 03:54

1 Answers1

1

If the error is

java.lang.IllegalArgumentException: No drawer view found with gravity LEFT

you can hava a try like this:

The childview of DrawerLayout must have either of the property set android:layout_gravity="start" OR android:layout_gravity="left". If you have set left or right, you can replace them with start or end.

And I hope you can show us the code the next time.

Motee
  • 112
  • 7
  • I have put layout_gravity as left|start on my child view which is a ListView. Is this the probable issue? – SPS Aug 06 '18 at 04:05
  • @SPS [https://stackoverflow.com/questions/27350136/android-drawerlayout-no-drawer-view-found-with-gravity](https://stackoverflow.com/questions/27350136/android-drawerlayout-no-drawer-view-found-with-gravity) hope the answer can help you – Motee Aug 06 '18 at 04:20