XML : Android cannot add map to fragment. android.view.InflateException: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag

I am trying to add a Google Map to a fragment in my android app and I am getting an android.view.InflateException

Background of the section of my app that is having problems:

  • I have implemented a TabLayout with ViewPager where each tab takes a fragment to display in the ViewPager
  • This uses a FragmentPagerAdapter
  • I have tested the API key etc separately and can display a basic map on my android device
  • I have tried using android:name="com.google.android.gms.maps.SupportMapFragment" and class="com.google.android.gms.maps.SupportMapFragment" in my XML layout for the map fragment

Here is a gist of some possible relevant files:

https://gist.github.com/ThrowingSpoon/dbd982c5720e4c27ed47

The error trace looks promising at these two locations:

Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)

ndroid.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class fragment at android.view.LayoutInflater.inflate(LayoutInflater.java:539) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at uk.co.liammartin.shout.RespondFragment2.onCreateView(RespondFragment2.java:27)

but have no idea where I am going wrong. Please help!

Thanks!

Liam.

No comments:

Post a Comment