I am working on an application in which I am having a drawerlayout and inside which I have a fragment.I am trying to use the jetpack navigation but the fragment gets the IllegalArgumentException issue.The code and the issue is as under
<?xml version="1.0" encoding="utf-8"?>
<layout 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"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.genie.vendor.ui.registration.RegistrationActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
style="@style/AppTheme.PopupOverlay"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<fragment
android:id="@+id/mainNavFragment"
class="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_main_graph"
tools:layout="@layout/activity_main" />
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/menu_main_drawer"/>
</androidx.drawerlayout.widget.DrawerLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.genie.vendorapplication/com.genie.vendor.ui.mainapp.MainActivity}: android.view.InflateException: Binary XML file line #36: Binary XML file line #36: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2928) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3063) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:198) at android.app.ActivityThread.main(ActivityThread.java:6729) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876) Caused by: android.view.InflateException: Binary XML file line #36: Binary XML file line #36: Error inflating class fragment Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class fragment Caused by: java.lang.IllegalArgumentException: Binary XML file line #36: Duplicate id 0x7f0900ec, tag null, or parent id 0xffffffff with another fragment for androidx.navigation.fragment.NavHostFragment
User contributions licensed under CC BY-SA 3.0