Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto"

This post share my experience on the error of Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto".

Recently, I re-check my old project using Google Maps Android API v2, it work without error before. But LogCat show error:

...
E/AndroidRuntime(20411): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
...
E/AndroidRuntime(20411): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
...

Then I re-visit the layout xml with MapFragment, error message show Unexpected namespace prefix "xmlns" found for tag fragment on the statement  xmlns:map="http://schemas.android.com/apk/res-auto".



To solve it, correct Java Build Path by right clicking on your project -> Java Build Path, select Order and Export tab, check both Android 4.2.2 and Android Private Libraries, and click OK.


And then clean and build the project.


Similar to the case: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo