I use the following XML code to create a MapFragment:
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.hashcoder.eegoomain.CustomerHomeActivity"/>
And in my onCreate()
method, I use the following code to initialize the map:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer_home);
createNavigationDrawerFunction();
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this); }
But, when I run this code on my phone (Redmi Note 4), it shows the following exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hashcoder.eegoomain/com.hashcoder.eegoomain.CustomerHomeActivity}: android.view.InflateException: Binary XML file line #61: Binary XML file line #61: Error inflating class fragment
And this code works fine in other devices. What am I doing wrong?