2021-04-18 15:18:12.620 5902-5902/com.example.myapplication E/AndroidRuntime:
FATAL EXCEPTION: main
Process: com.example.myapplication, PID: 5902
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.myapplication/ com.example.myapplication.MainActivity}:
android.view.InflateException: Binary XML file
line #9 in com.example.myapplication:layout/ activity_main:
Binary XML file line #9 in com.example.myapplication:layout/activity_main:
Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException: Binary XML file line #9 in
com.example.myapplication:layout/activity_main:
Binary XML file line #9 in com.example.myapplication:layout/activity_main:
Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException:
Binary XML file line #9 in com.example.myapplication:layout/activity_main:
Error inflating class android.support.v7.widget.Toolbar
Caused by: java.lang.ClassNotFoundException: android.support.v7.widget.Toolbar
at java.lang.Class.classForName(Native Method)
If you get the above error message in Android Studio LogCat Logs and your App crashes, the reason is you are trying to use android.support.v7.widget.Toolbar class that does not exist, its better to use androidx.appcompat.widget.Toolbar instead.
Example:<androidx.appcompat.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

Have Questions? Post them here!
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!