runtime error after migrating to androidX

I just wanted to build a signed apk, then I got lots of errors which I realized most of them would be solved by migrating to android X, but I get this runtime error after migrating to androidX:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.hamed/com.test.hamed.cups}: android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class

where line #18 that is mentioned is:


and in Java is this line in onCretae:

protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.cups); // <= this line

I have searched a lot and some suggest that adding the following line would solve the problem but it didn’t:

    implementation ''

What is the problem and how can I fix this? Thanks


The correct usage for AppBarLayout is now