Binary XML file line #73: Error inflating class com.mikepenz.materialdrawer.widget
kaushiksa opened this issue · 10 comments
Getting this error. I am using version 8.4.4 .
.InflateException: Binary XML file line #73: Binary XML file line #73: Error inflating class com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: android.view.InflateException: Binary XML file line #73: Binary XML file line #73: Error inflating class com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
Caused by: android.view.InflateException: Binary XML file line #73: Error inflating class com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at com.projects.finzen.MainActivity.onCreate(MainActivity.kt:27)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
dependencies:
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:28.4.2')
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
implementation "androidx.viewpager2:viewpager2:1.0.0"
implementation 'me.relex:circleindicator:2.1.6'
implementation 'com.airbnb.android:lottie:4.2.0'
implementation "androidx.navigation:navigation-fragment-ktx:2.3.5" // Navigation
implementation "androidx.navigation:navigation-ui-ktx:2.3.5" // Navigation
implementation "org.koin:koin-android:2.0.0-beta-1"
testImplementation "org.koin:koin-test:2.0.0"
implementation 'com.google.code.gson:gson:2.8.8' // Gson
implementation 'com.github.AppIntro:AppIntro:6.1.0'
implementation "androidx.datastore:datastore-preferences:1.0.0"
// for drawer
implementation "com.mikepenz:materialdrawer:8.4.4"
//required support lib modules
implementation "androidx.recyclerview:recyclerview:1.2.1"
// Add for NavController support
implementation "com.mikepenz:materialdrawer-nav:8.4.4"
// Add for Android-Iconics support
implementation "com.mikepenz:materialdrawer-iconics:8.4.4"
Have also added styles in theme
@kaushiksa can you please provide additional details. I adjusted the sample app to use almost exactly the same set of libraries you describe, but the crash won't occur.
https://github.com/mikepenz/MaterialDrawer/tree/issue/2752
Do you do any other modification to the layouts of the library? Which theme do you use?
hey @mikepenz . thanks for the reply. I haven't made any modification in the library's layouts.
my layout looks like this
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="63dp"
android:fontFamily="@font/roboto"
android:gravity="center"
android:text="You are now logged in !"
android:textColor="@color/black"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="@+id/LogOut"
android:layout_width="221dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Log Out"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="16sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
android:id="@+id/slider"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true" />
</androidx.drawerlayout.widget.DrawerLayout>
and below is my theme.xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.FinZen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="materialDrawerStyle">@style/Widget.MaterialDrawerStyle</item>
<item name="materialDrawerHeaderStyle">@style/Widget.MaterialDrawerHeaderStyle</item>
</style>
</resources>
@kaushiksa can you please double check that the theme is really used?
Otherwise I'd please need a sample app to reproduce the project, as I seem to not be able to reproduce it in the sample app itself
i have the same issue
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hussein.aya, PID: 3915
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hussein.aya/com.hussein.aya.Activities.Home.HomePageActivity}: android.view.InflateException: Binary XML file line #159 in com.hussein.aya:layout/activity_home_page: Binary XML file line #159 in com.hussein.aya:layout/activity_home_page: Error inflating class com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3782)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:8178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Caused by: android.view.InflateException: Binary XML file line #159 in com.hussein.aya:layout/activity_home_page: Binary XML file line #159 in com.hussein.aya:layout/activity_home_page: Error inflating class com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
Caused by: android.view.InflateException: Binary XML file line #159 in com.hussein.aya:layout/activity_home_page: Error inflating class com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:864)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:699)
at androidx.appcompat.app.LocaleHelperAppCompatDelegate.setContentView(LocaleHelperAppCompatDelegate.kt:49)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:303)
at androidx.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:284)
at com.hussein.aya.Activities.Home.HomePageActivity.onCreate(HomePageActivity.kt:78)
at android.app.Activity.performCreate(Activity.java:8086)
at android.app.Activity.performCreate(Activity.java:8074)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1313)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3755)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3961)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2386)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:8178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f0400f4 a=10}
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:1198)
at android.content.res.TypedArray.getDrawable(TypedArray.java:1182)
at com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView.(MaterialDrawerSliderView.kt:399)
at com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView.(MaterialDrawerSliderView.kt:49)
at com.mikepenz.materialdrawer.widget.MaterialDrawerSliderView.(Unknown Source:11)
... 31 more
@hussein16hamada please provide which theme is used, which version of the library.
As noted here: https://github.com/mikepenz/MaterialDrawer/tree/issue/2752 I was not able to reproduce this
version is 8.4.5 and this is the theme
<style name="AppTheme.Base" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/lightblue</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="actionModeBackground">@color/accent</item>
<item name="android:fontFamily">@font/uthman</item>
<item name="android:textColor">#5c9093</item>
<item name="android:statusBarColor" tools:ignore="NewApi">@color/lightblue</item>
<item name="android:navigationBarColor" tools:ignore="NewApi">@color/lightblue</item>
</style>
@hussein16hamada the library (in v8.x) requires a MaterialComponents
theme as base:
https://github.com/mikepenz/MaterialDrawer/tree/v8.4.5#3-add-the-drawerstyle-to-your-theme
v9.x will require a Material3
theme as base.
okay thanks
@hussein16hamada I can't assist with the setup for the material theme for a whole application itself. Only for this library related matter.
Please refer to the official google docs for the MaterialComponents
theme: https://material.io/develop/android
Closing due to inactivity. Please (original author) report back if this is still a concern