0

I just switched to Android Studio from Eclipse. For the first two week, the Map Fragment was working for my two devices, one with Android version 4.1.2 and the other 5.0.

This past Friday, something strange happened:

For my device w/ 4.1.2 Android, I got this error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mycompany.myproject/com.mycompany.myproject.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment

It works perfectly fine on my device with 5.0.2.

Any idea?

A snippet of the layout file...

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/MainActivityContainer"
    tools:context=".MainActivity" >

    <fragment
        android:name="com.google.android.gms.maps.MapFragment"
        android:id="@+id/map_fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

EDIT:

Apparently, there's nothing wrong w/ the code and XML, because I create a brand new project and copy-and-paste the code and XML that project and everything work as it is supposed to. Does anyone know if there's a configuration on an Android Studio project that could limit the use of map fragment?

Johnny Wu
  • 1,297
  • 15
  • 31
  • Possible dupe of http://stackoverflow.com/questions/14082851/error-inflating-class-fragment-with-google-map ? – alzee Dec 13 '15 at 23:01
  • @user3137702...I read that one and made the change, but still no luck. Thanks for the response. – Johnny Wu Dec 14 '15 at 02:47

2 Answers2

0

Have you checked your 'Manifest' file ? and checked the SDKVersions ? (Sorry i can't comment i don't have 50 rep yet lol)

Scott B
  • 219
  • 2
  • 3
  • 11
0

SOLVED IT!!!! OMG!!

The problem was in the Manifest with the WRITE_EXTERNAL_STORAGE permission!!

I was able to narrow down the permission in the manifest and removed it...now I can live happily ever after. :)

Johnny Wu
  • 1,297
  • 15
  • 31
  • Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. - [From Review](/review/low-quality-posts/10844594) – Rohit Gupta Jan 11 '16 at 01:16
  • @RohitGupta ... This IS the solution: by removing the WRITE_EXTERNAL_STORAGE permission from the manifest...well, at this in my scenario anyway. :) – Johnny Wu Jan 11 '16 at 02:03