0

This is my configuration below. This works on android emulator version Kitkat but crashes on my actual phone version Lollipop.

I tried every way in here but I still get the same error. Error inflating class android.support.design.widget.NavigationView

This is my build gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.kim.deptenv2"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:design:25.3.1'
    compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.github.bloder:magic:1.1'
    testCompile 'junit:junit:4.12'
}

Layout activity_user_area.xml

<?xml version="1.0" encoding="utf-8"?>
<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/dtMenu"
    tools:context="com.example.kim.deptenv2.UserAreaActivity">

    <FrameLayout
        android:layout_width="match_parent"
        android:background="@drawable/bg112"
        android:layout_height="wrap_content"
        android:id="@+id/f1content">

        <TextView
            android:id="@+id/tvIDD"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentStart="true"
            android:layout_marginBottom="19dp"
            android:layout_marginStart="14dp"
            android:text="TextView"
            android:visibility="invisible"/>
        <TextView
            android:id="@+id/deyto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:layout_marginLeft="220dp"
            android:fontFamily="serif"
            android:textSize="18dp"
            android:text="Mmm dd, yyy"
            android:visibility="visible"/>

        <TextView
            android:id="@+id/tvSxe"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"
            android:layout_above="@+id/tvIDD"
            android:layout_alignStart="@+id/tvIDD"
            android:visibility="invisible" />
        <TextView
            android:id="@+id/tvuserID"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"
            android:visibility="invisible" />

        <br.com.bloder.magic.view.MagicButton
            android:id="@+id/startTezt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:button_icon="@drawable/startest"
            app:button_icon_height="45dp"
            app:button_icon_width="45dp"
            app:expandable_area_color="#b0afe2"
            app:hide_text="Svl Start Test"
            app:hide_text_color="#636691"
            app:hide_text_size="30dp"
            app:icon_button_color="#9da3d2"
            android:layout_marginTop="370dp"
            android:layout_marginLeft="150dp"
            app:magic_button_size="70dp" />


        <Button
            android:layout_width="260dp"
            android:layout_height="260dp"
            android:layout_marginTop="100dp"
            android:layout_marginLeft="50dp"
            android:background="@drawable/logodepten"/>
    </FrameLayout>

    <android.support.design.widget.NavigationView
        app:headerLayout="@layout/navheader"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/nv"
        app:itemTextColor="@color/colorText5"
        app:itemIconTint="@color/colorText5"
        app:menu="@menu/drawermenu"
        android:layout_gravity="start">


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



</android.support.v4.widget.DrawerLayout>

The navheader.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:background="@drawable/navheader"
    android:padding="20dp"
    >

    <ImageView
        android:src="@drawable/homeicon"
        android:layout_width="75dp"
        android:layout_height="75dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="USER'S FULLNAME"
        android:textColor="@color/colorText3"
        android:textStyle="bold"
        android:layout_marginTop="5dp"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/colorText3"
        android:text="usersemail@gmail.com"/>
</LinearLayout>

This is the logcat error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kim.deptenv2/com.example.kim.deptenv2.UserAreaActivity}: android.view.InflateException: Binary XML file line #77: Error inflating class android.support.design.widget.NavigationView
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2348)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410)
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                              at android.os.Looper.loop(Looper.java:135)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5345)
                                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:372)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742)
                                                                              at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
                                                                           Caused by: android.view.InflateException: Binary XML file line #77: Error inflating class android.support.design.widget.NavigationView
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:633)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                                              at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
                                                                              at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
                                                                              at android.view.LayoutInflater.inflate(<Xposed>)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                              at com.example.kim.deptenv2.UserAreaActivity.onCreate(UserAreaActivity.java:37)
                                                                              at android.app.Activity.performCreate(Activity.java:6012)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5345) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) 
                                                                              at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) 
                                                                           Caused by: java.lang.reflect.InvocationTargetException
                                                                              at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:607)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                                                                              at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                              at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) 
                                                                              at android.view.LayoutInflater.inflate(<Xposed>) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                              at com.example.kim.deptenv2.UserAreaActivity.onCreate(UserAreaActivity.java:37) 
                                                                              at android.app.Activity.performCreate(Activity.java:6012) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5345) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) 
                                                                              at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) 
                                                                           Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:633)
                                                                              at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
                                                                              at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
                                                                              at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
                                                                              at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334)
                                                                              at android.view.LayoutInflater.inflate(<Xposed>)
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                                              at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:211)
                                                                              at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:269)
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:178)
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:100)
                                                                              at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                                                                              at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                              at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) 
                                                                              at android.view.LayoutInflater.inflate(<Xposed>) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                              at com.example.kim.deptenv2.UserAreaActivity.onCreate(UserAreaActivity.java:37) 
                                                                              at android.app.Activity.performCreate(Activity.java:6012) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5345) 
                                                                              at java.lang.reflect.Method.invoke(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) 
                                                                              at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102) 
                                                                           Caused by: java.lang.reflect.InvocationTargetException
                                                                              at java.lang.reflect.Constructor.newInstance(Native Method)
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:607)
                                                                              at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
                                                                              at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:482) 
                                                                              at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                              at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) 
                                                                              at android.view.LayoutInflater.inflate(<Xposed>) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                                              at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:211) 
                                                                              at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:269) 
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:178) 
                                                                              at android.support.design.widget.NavigationView.<init>(NavigationView.java:100) 
                                                                              at java.lang.reflect.Constructor.newInstance(Native Method) 
                                                                              at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
                                                                              at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
                                                                              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 
                                                                              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
                                                                              at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                              at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:334) 
                                                                              at android.view.LayoutInflater.inflate(<Xposed>) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
                                                                              at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
                                                                              at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                                                                              at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                              at com.example.kim.deptenv2.UserAreaActivity.onCreate(UserAreaActivity.java:37) 
                                                                              at android.app.Activity.performCreate(Activity.java:6012) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 

1 Answers1

1

please try comment out this two lines. If it solved the problem, mean that your color code is wrong.

Refer: https://github.com/Marketcloud/marketcloud-sample-android-application/issues/1

<android.support.design.widget.NavigationView
        app:headerLayout="@layout/navheader"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:id="@+id/nv"
        app:itemTextColor="@color/colorText5"
        app:itemIconTint="@color/colorText5"
        app:menu="@menu/drawermenu"
        android:layout_gravity="start">

Beside above solution, there is another one that causing this. It was theme.

In your manifest, inside the main activity part, are there any line of this code:

android:theme="@style/Theme.AppCompat.Light">

As this can create a lot of problems, because it may not be totally compatible with some graphics I used in the sample. The solution is creating this theme in your styles-v21.xml (it should already be there if you imported the sample files, but if it is not there, please create it):

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

And calling it in the manifest, in the main activity part, as follows (delete the line I highlighted earlier and put this in its place):

android:theme="@style/AppTheme.NoActionBar">
Kasnady
  • 2,249
  • 3
  • 25
  • 34
  • Glad to hear it.. Which part of the solution solved your problem? @KimGangoso – Kasnady Feb 20 '18 at 02:59
  • When I commented the two lines you pointed out, it worked. Maybe my color code is wrong. Also, I think the resolution of my navheader background also matters. I get rid of it and works. Thank you so much! – Kim Gangoso Feb 20 '18 at 03:14
  • @KimGangoso Ok. Glad to hear it.. Cheers – Kasnady Feb 20 '18 at 03:16