skip to Main Content

This is the error I have been getting after changing the package name of the project

I have already refactored everything related to the previous package name.

FYI I changed the package name using the refactoring option in android studio

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.nectardigit.khadyabank, PID: 7053
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nectardigit.khadyabank/com.nectardigit.khadyabank.user.HomeActivity}: android.view.InflateException: Binary XML file line #15: Binary XML file line #10: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        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:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        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:858)
     Caused by: android.view.InflateException: Binary XML file line #15: Binary XML file line #10: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
     Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.nectardigit.eshopping.user.ui.home.HomeFragment: make sure class name exists
        at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:97)
        at androidx.fragment.app.Fragment.instantiate(Fragment.java:611)
        at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
        at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:483)
        at androidx.navigation.fragment.FragmentNavigator.instantiateFragment(FragmentNavigator.java:132)
        at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:162)
        at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:58)
        at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:71)
        at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:28)
        at androidx.navigation.NavController.navigate(NavController.java:1066)
        at androidx.navigation.NavController.onGraphCreated(NavController.java:639)
        at androidx.navigation.NavController.setGraph(NavController.java:592)
        at androidx.navigation.NavController.setGraph(NavController.java:557)
        at androidx.navigation.NavController.setGraph(NavController.java:539)
        at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:248)
        at androidx.fragment.app.Fragment.performCreate(Fragment.java:2949)
        at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:475)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278)
        at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:140)
        at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
        at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319)
        at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:780)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:995)
E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:706)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.nectardigit.khadyabank.user.HomeActivity.onCreate(HomeActivity.java:93)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        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:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        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:858)
     Caused by: java.lang.ClassNotFoundException: com.nectardigit.eshopping.user.ui.home.HomeFragment
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at androidx.fragment.app.FragmentFactory.loadClass(FragmentFactory.java:53)
        at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:94)
            ... 54 more
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nectardigit.eshopping.user.ui.home.HomeFragment" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.nectardigit.khadyabank-qlEtyxVsrKYsD-VNMnVfqg==/base.apk"],nativeLibraryDirectories=[/data/app/com.nectardigit.khadyabank-qlEtyxVsrKYsD-VNMnVfqg==/lib/x86, /data/app/com.nectardigit.khadyabank-qlEtyxVsrKYsD-VNMnVfqg==/base.apk!/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
            ... 58 more
I/Process: Sending signal. PID: 7053 SIG: 9

    at com.nectardigit.khadyabank.user.HomeActivity.onCreate(HomeActivity.java:93)

This above line points to this line

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home); <========== HERE

Things I have already tried to fix:

  • Clean and rebuild project
  • invalidate cache and restart
  • check every reference to the old package name

The activity_home that has not been instantiating

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include
            layout="@layout/app_bar_home"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="60dp" />

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottom_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="?android:attr/windowBackground"
            app:itemIconTint="@drawable/bottom_nav_selector"
            app:itemRippleColor="@color/bottom_nav_ripple"
            app:itemTextColor="@drawable/bottom_nav_selector"
            app:menu="@menu/bottom_nav_menu" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <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">

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="110dp"
                    android:background="#03A64A"
                    android:gravity="bottom"
                    android:orientation="horizontal"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="25dp"
                        android:layout_marginBottom="20dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal">

                        <de.hdodenhof.circleimageview.CircleImageView
                            android:id="@+id/profile_image"
                            android:layout_width="50dp"
                            android:layout_height="50dp"
                            android:src="@drawable/image_dummy_small" />

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="5dp"
                            android:orientation="vertical">

                            <TextView
                                android:id="@+id/name"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:fontFamily="@font/poppins"
                                android:textAppearance="@style/TextAppearance.AppCompat.Body1"
                                android:textColor="@color/white"
                                android:textSize="15sp" />

                            <TextView
                                android:id="@+id/reward"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:fontFamily="@font/poppins"
                                android:textAppearance="@style/TextAppearance.AppCompat.Body1"
                                android:textColor="@color/white"
                                android:textSize="15sp"
                                android:visibility="gone" />

                        </LinearLayout>

                    </LinearLayout>

                </LinearLayout>

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/navigationRecycler"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="10dp" />

                <LinearLayout
                    android:id="@+id/orderHistoryGroup"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginTop="5dp"
                        android:background="@color/view_background" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="10dp"
                        android:text="Order History"
                        android:textSize="14sp" />

                    <LinearLayout
                        android:id="@+id/nav_purchases"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal"
                        android:padding="8dp">

                        <ImageView
                            android:layout_width="25dp"
                            android:layout_height="25dp"
                            android:layout_marginStart="10dp"
                            android:contentDescription="@string/app_name"
                            android:src="@drawable/icon_purchase" />

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:text="Purchases"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/nav_pending"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal"
                        android:padding="8dp">

                        <ImageView
                            android:layout_width="25dp"
                            android:layout_height="25dp"
                            android:layout_marginStart="10dp"
                            android:contentDescription="@string/app_name"
                            android:src="@drawable/icon_purchase" />

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:text="Pending"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/nav_returns"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal"
                        android:padding="8dp">

                        <ImageView
                            android:layout_width="25dp"
                            android:layout_height="25dp"
                            android:layout_marginStart="10dp"
                            android:contentDescription="@string/app_name"
                            android:src="@drawable/icon_purchase" />

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:text="Returns"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <LinearLayout
                        android:id="@+id/nav_cancellations"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal"
                        android:padding="8dp">

                        <ImageView
                            android:layout_width="25dp"
                            android:layout_height="25dp"
                            android:layout_marginStart="10dp"
                            android:contentDescription="@string/app_name"
                            android:src="@drawable/icon_purchase" />

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="15dp"
                            android:text="Cancellations"
                            android:textSize="14sp" />
                    </LinearLayout>

                </LinearLayout>


                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_marginTop="5dp"
                    android:background="@color/view_background" />

                <LinearLayout
                    android:id="@+id/compareLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:padding="8dp">

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_marginStart="10dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/icon_compare" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="15dp"
                        android:text="Compare"
                        android:textSize="14sp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/newsLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:padding="8dp">

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_marginStart="10dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/icon_news" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="15dp"
                        android:text="News"
                        android:textSize="14sp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/helpLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:padding="8dp">

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_marginStart="10dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/icon_help" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="15dp"
                        android:text="Help"
                        android:textSize="14sp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/loginLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:padding="8dp">

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_marginStart="10dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/icon_login" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="15dp"
                        android:text="Login"
                        android:textSize="14sp" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/logoutLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:padding="8dp">

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_marginStart="10dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/icon_logout" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="15dp"
                        android:text="Log Out"
                        android:textSize="14sp" />
                </LinearLayout>

            </LinearLayout>

        </androidx.core.widget.NestedScrollView>

    </com.google.android.material.navigation.NavigationView>

</androidx.drawerlayout.widget.DrawerLayout>

App_bar_home XML FILE

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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=".user.HomeActivity">

    <com.google.android.material.appbar.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="@color/toolbarBgColor"
            android:elevation="4dp"
            android:theme="@style/ThemeOverlay.MaterialComponents.Light"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:titleTextAppearance="@style/Toolbar.TitleText"
            app:titleTextColor="@color/textColor" />

    </com.google.android.material.appbar.AppBarLayout>

    <include layout="@layout/content_home" />

    <!--<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        app:srcCompat="@android:drawable/ic_dialog_email" />-->

</androidx.coordinatorlayout.widget.CoordinatorLayout>

2

Answers


  1. Also change path to R file in import section.

    Login or Signup to reply.
  2. Referring to these log lines:

    ...
    Binary XML file line #15: Binary XML file line #10: Error inflating class fragment
    ...
    Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.nectardigit.eshopping.user.ui.home.HomeFragment: make sure class name exists
    ...
    

    Try checking your xml file R.layout.activity_home.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search