Cannot convert from android.support.v4.app.Fragment to android.app.Fragment Cannot convert from android.support.v4.app.Fragment to android.app.Fragment android android

Cannot convert from android.support.v4.app.Fragment to android.app.Fragment


Whats going on here?

While the Android Support package gives you a backwards-compatible Fragment implementation, the ActionBar is not part of the Android Support package. Hence, ActionBar.TabListener is expecting native API Level 11 Fragment objects. Consider using ActionBarSherlock to have both an action bar and Android Support fragments.

but then I'm left with another problem in my FragmentPagerAdapter

The FragmentPagerAdapter in the Android Support package is a bit messy -- it wants API Level 11 Fragment objects, not Android Support Fragment objects. However, you can clone the source to FragmentPagerAdapter (source is in your SDK) and create your own implementation that uses the support.v4 flavor of Fragment and kin.


I know that it has been too late to answer this question but it might help someone with the same problem.

Go to your java folder and click on your fragment's activity.

In the imports, replace import android.app.Fragment; with

import android.support.v4.app.Fragment;

Keep the code in the MainActivity intact and this should help resolve the issue.

Note: If it doesn't work at once, don't worry. Build > Rebuild project.