Edit:
As per this link, this is a bug.
For a workaround, Add this comment above the line of code which gives the warning:
//noinspection RestrictedApi
Old Ans:
I hope you are not importing wrong library. Fragment support library supports fragment for devices running versions prior to Android3.0.
As per this post in SO
Also remember to use Activity if you are using android.app.Fragment;
use FragmentActivity if you are using android.support.v4.app.Fragment.
Never attach a android.support.v4.app.Fragment to an android.app.Activity,
as this will cause an exception to be thrown.
android.app.Fragment
is different than android.support.v4.app.Fragment
.
The support library one is annotated @RestrictTo(LIBRARY_GROUP)
, and also @hide
- it's not meant to be a public API.