11

I use DrawerLayout and Hamburger menu in my App. I migrated my App to Androidx. Everything it seems right but DrawerLayout. It doesn't know DrawerLayout Class.

What I have to do?

Fcoder
  • 9,066
  • 17
  • 63
  • 100

4 Answers4

18

AndroidX has its implementation of DrawerLayout.

Add implementation "androidx.drawerlayout:drawerlayout:1.0.0" to your module's dependencies (you can check Google's Maven repository catalog to confirm the available versions).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Just to correct a little typo, is "implementation 'androidx.drawerlayout:drawerlayout:1.0.0'" (notice the . after drawerlayout) – moictab Jun 24 '19 at 11:49
17

you sould replace drawerlayout in xml with below line

androidx.drawerlayout.widget.DrawerLayout
mmfarzaneh
  • 381
  • 1
  • 11
3

Add implementation "androidx.drawerlayout:drawerlayout:1.0.0" in your build.gradle file, then in the layout file you want to use drawer layout, change <androidx.core.widget.DrawerLayout tag to <androidx.drawerlayout.widget.DrawerLayout.

Bukunmi
  • 2,504
  • 1
  • 18
  • 15
  • What is the difference between those two? I have both available, but the `core` drawer does not allow `FrameLayout` as a child element, while the other one allows it (like the `support` drawer did). – Minding Aug 02 '19 at 23:18
1
  1. First step:

    implementation "androidx.drawerlayout:drawerlayout:1.0.0"

  2. add on top of your layout add:

    <androidx.drawerlayout.widget.DrawerLayout>

  3. Must end by closing tag:

    </androidx.drawerlayout.widget.DrawerLayout>

ImAtWar
  • 1,073
  • 3
  • 11
  • 23