The answer to your question is in this post. This is a recurring question:
isValidFragment Android API 19
- Updated -
Here is what the solution is:
Basically, whatever activity your "com ... $" snippet uses in the above error, you should update it with the fix below. You must update all the activities in your project with this patch for any Acitvity that uses the fragment.
The documentation states:
protected boolean isValidFragment (String fragmentName) Added in API level 19 Subclasses should override this method and verify that the given fragment is a valid type to be attached to this activity. The default implementation returns true for apps built for android:targetSdkVersion older than KITKAT. For later versions, it will throw an exception.
You can fix this error by overriding this method in Activity / FragmentActivity:
@Override protected boolean isValidFragment (String fragmentName) { return [YOUR_FRAGMENT_NAME_HERE].class.getName().equals(fragmentName); }
If you are lazy and just want to check if this fix works before encoding all your fragments into this method, you can simply return true without any check:
@Override protected boolean isValidFragment (String fragmentName) { return true; }
I had the same problems when testing on an emulator, and that was the solution.
Camille sevigny
source share