Error inflating class android.support.v4.view.ViewPager

Make sure that you place your libraries in a common folder such as libs in your project.

Right click on the jar, then select Build Path and click on Add to Build Path.

That will add your library to your project. If everything is correct, you can see it in a generated "folder" in the project called "Referenced Libraries"


Go to Project → Properties → Java Build Path than select Order and Export tab.

Set android-support-v4.jar library checked and up it into top of the list. And clean and rebuild..It works for most of the cases


I simply Replaced the code with this and it worked

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/main_tabPager"
        android:layout_width="match_parent">