j2emanue j2emanue - 5 months ago 19
Android Question

android NavigationView not found

I have the following xml:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/container"
/>

<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
/>
</android.support.v4.widget.DrawerLayout>


but im getting the error that
no such class android.support.design.widget.NavigationView


here is my sdk configuration in gradle:

minSdkVersion 16
targetSdkVersion 23


I'm not allowed to use jcenter or a remote repository in my project for security reasons so i have to always include dependencies as jar file. How can i fix this error ?

Answer

You have this error because you need the Design Support Library.

Download with the SDK Manager the Android Support Repository, than you can find the last version of the library here:

<android-sdk>/extras/android/m2repository/com/android/support/design/23.0.1/design-23.0.1.aar

Copy it in your libs directory then add the dependency to your build.gradle:

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile 'android.support.design:design:23.0.1@aar'
}
Comments