Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView
Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView
When I run app on Android I get this message:
08-20 17:38:26.542 5016-5016/? E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfocom.aplikacija.android.bluetoothscanner/com.aplikacija.android.bluetoothscanner.Activities.MainActivity: android.view.InflateException: Binary XML file line ##30: Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2490)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2550)
at android.app.ActivityThread.access$1100(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5615)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Caused by: android.view.InflateException: Binary XML file line #30: Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView
at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.aplikacija.android.bluetoothscanner.Activities.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:6362)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2443)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2550)
at android.app.ActivityThread.access$1100(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1401)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5615)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#3F51B5</item>
<item name="colorPrimaryDark">#303F9F</item>
<item name="colorAccent">#FF4081</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
<style name="AppTheme.CustomTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
activity_main.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"
tools:context=".Activities.MainActivity"
android:id="@+id/drawer_layout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/navigation_action"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<include
layout="@layout/content_scan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/add_room_include"/>
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@menu/navigation_menu"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.aplikacija.android.bluetoothscanner"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Activities.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.CustomTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".Activities.ScanActivity" android:theme="@style/AppTheme.CustomTheme"></activity>
<activity android:name=".Activities.ManageActivity" android:theme="@style/AppTheme.CustomTheme"></activity>
<activity android:name=".Activities.ListRoomsActivity" android:theme="@style/AppTheme.CustomTheme"></activity>
<activity android:name=".Activities.EditDataActivity" android:theme="@style/AppTheme.CustomTheme"></activity>
<activity android:name=".Activities.ListConnectionsActivity" android:theme="@style/AppTheme.CustomTheme"></activity>
<receiver android:name="com.aplikacija.android.bluetoothscanner.MyBluetoothReceiver"></receiver>
</application>
navigation_header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="110dp"
android:background="@color/colorPrimary">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:paddingLeft="20dp"
android:paddingTop="20dp"
android:text="Navigation bar"
android:textColor="@android:color/white"
android:textSize="20sp"/>
</RelativeLayout>
MainActivity.java
package com.aplikacija.android.bluetoothscanner.Activities;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import com.aplikacija.android.bluetoothscanner.R;
public class MainActivity extends AppCompatActivity
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mToggle;
private android.support.v7.widget.Toolbar mToolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.nav_action);
setSupportActionBar(mToolbar);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);
mDrawerLayout.addDrawerListener(mToggle);
mToggle.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@Override
public boolean onOptionsItemSelected(MenuItem item)
if(mToggle.onOptionsItemSelected(item))
return true;
return super.onOptionsItemSelected(item);
public void manageRoomsOnClick()
setContentView(R.layout.activity_main);
navigation_action.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar android:id="@+id/nav_action"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
</android.support.v7.widget.Toolbar>
content_scan.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".Activities.MainActivity"
tools:showIn="@layout/activity_scan"
android:id="@+id/relativeLayoutContentMain">
<RelativeLayout
android:id="@+id/scanning_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginBottom="-87dp">
<ProgressBar
android:id="@+id/progressBar"
style="@android:style/Widget.Holo.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginEnd="16dp"
android:progressDrawable="@drawable/circular_progress_view"
android:visibility="invisible"/>
<Button
android:id="@+id/btnScan"
android:layout_width="187dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="18dp"
android:text="Start scan"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/includedLayout"
android:layout_width="match_parent"
android:layout_height="312dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="78dp">
<include
layout="@layout/list_connections_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="12dp">
<Button
android:id="@+id/btnViewConenctions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:text="View Connections"/>
<Button
android:id="@+id/btn_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="23dp"
android:text="Stop"/>
</RelativeLayout>
</RelativeLayout>
Can you please help me to resolve this issue?
I know that here on Stackoverflow is many questions with the same problem.
I tried some of their answers but I got the same exception.
Please help. Thank you!
@UmangBurman I added MainActivity.java
– Jakov Plese
Aug 20 at 16:13
@menu/navigation_menu
or @layout/navigation_header
might be missing.– Martin Zeitler
Aug 20 at 16:19
@menu/navigation_menu
@layout/navigation_header
@MartinZeitler I looked at the files and they are here. Thanks anyway.
– Jakov Plese
Aug 20 at 19:09
2 Answers
2
It seems you need to import the support library
go to your app>build.gradle in dependencies
dependencies
implementation 'com.android.support:design:27.1.1'
I tried, but it did not help. Thanks anyway.
– Jakov Plese
Aug 20 at 19:06
Try to remove the app:menu at navigation view
– R7G
Aug 20 at 20:05
Thanks. I found problem in "navigation_menu.xml"
– Jakov Plese
Aug 20 at 20:53
Can you please post the layout xml files for @layout/navigation_action & @layout/content_scan.
I think you are having some vector drawables issues for pre-lollipop devices within these layout files.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Can you also post the java file in which you are getting this error
– Umang Burman
Aug 20 at 16:06