i am making navigation drawer but it crashes with following error:
Error inflating class android.support.design.widget.NavigationView
here is my code
mainactivity
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.support.v4.widget.DrawerLayout
import android.support.v7.app.ActionBarDrawerToggle
class MainActivity : AppCompatActivity() {
lateinit var mdrawerlayout:DrawerLayout
lateinit var mToggle:ActionBarDrawerToggle
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
mdrawerlayout = findViewById(R.id.DrawerId)
mToggle = ActionBarDrawerToggle(this,mdrawerlayout,R.string.open,R.string.close)
mdrawerlayout.addDrawerListener(mToggle)
mToggle.syncState()
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
}
}
my xml layout
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/DrawerId"
tools:context="com.bird.play.MainActivity">
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@menu/menu"
/>
</android.support.v4.widget.DrawerLayout>
here is the error cant post full error
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bird.play/com.bird.play.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3168)
at com.bird.play.MainActivity.onCreate(MainActivity.kt:18)
both of my support design and app compact library have the same version 26.1.0 build gradle
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.bird.play"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}