[Solved] AS Error: Error inflating class android.support.v4.view.ViewPager

There is a problem when using viewpager in XML:
error inflating class android.support.v4.view.viewpager

Solution:

Change android.support.v4.view.viewpager to

androidx.viewpager.widget.ViewPager

If there is still a red exclamation mark, just click
change to android.viewpager.widget.viewpager as prompted.

Read More: