Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Didn't find class Error inflating class android.support.design.widget.BottomNavigationView

What I am missing ? I followed up those answers error-inflating-class-android , support-design-widget-navigationview. but still gettin this error

 Error inflating class android.support.design.widget.BottomNavigationView
Didn't find class "android.support.design.widget.BottomNavigationView" on path: DexPathList[[zip file ...

my MainActivity includes AppCompatActivity :

public class MainActivity extends AppCompatActivity   implements NavigationView.OnNavigationItemSelectedListener {

my gradle is :

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:recyclerview-v7:23.0.+'

my style is :

<!-- Base application theme. -->
<style name="AppTheme" parent="Base.AppTheme">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="Base.AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="android:colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="Theme.AppCompat.Light.DarkActionBar" />

<style name="AppTheme.PopupOverlay" parent="Theme.AppCompat.Light.DarkActionBar" />

my xml is :

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/liner1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>


    <TextView
        android:id="@+id/textView3"
        android:layout_width="match_parent"
        android:layout_height="25dp"
        android:layout_above="@+id/recyclerview1"
        android:gravity="center"
        android:background="#10bcc9"
        android:textColor="@android:color/white"
        android:text="New Games." />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview1"
        android:layout_width="wrap_content"
        android:layout_height="140dp"
        android:scrollbars="horizontal" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="match_parent"
        android:layout_height="25dp"
        android:layout_below="@+id/recyclerview1"
        android:gravity="center"
        android:background="#10bcc9"
        android:textColor="@android:color/white"
        android:text="Used Games." />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/maingridrc"
        android:layout_width="wrap_content"
        android:layout_height="330dp"
        android:layout_marginTop="5dp"
        android:scrollbars="vertical" />

  <!--  <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />-->
</LinearLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:menu="@menu/my_navigation_items" />

</RelativeLayout>

in SDK manager :

enter image description here

like image 930
Moudiz Avatar asked Aug 14 '17 10:08

Moudiz


2 Answers

After you migrate to AndroidX replace

android.support.design.widget.BottomNavigationView

with

com.google.android.material.bottomnavigation.BottomNavigationView
like image 84
deinier Avatar answered Oct 30 '22 10:10

deinier


BottomNavigationView has been added to Support Library Revision 25.0.0 only.

https://developer.android.com/topic/libraries/support-library/revisions.html#rev25-0-0

You are using old version:

compile 'com.android.support:design:23.1.1'

Up all the support libraries that you are using to version 25.0.0

like image 42
Bob Avatar answered Oct 30 '22 10:10

Bob