title: Why my map app crashes if I set maxSdkVersion in the WRITE_EXTERNAL_STORAGE permission?
body: <p>I've set my map following the instructions in <a href="https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2" rel="nofollow">this link</a>. And set the <code>WRITE_EXTERNAL_STORAGE</code> permission in accordance with the recomended by the <a href="http://developer.android.com/guide/topics/manifest/uses-permission-element.html" rel="nofollow">Official Android Documentation</a>, that is request this permission only for API level 18 and lower. So, I have this manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.myapp" &gt;
  
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
                       android:maxSdkVersion="18"/&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
      &lt;uses-permission android:name="android.permission.android.permission.ACCESS_COARSE_LOCATION"/&gt;
      &lt;uses-permission android:name="android.permission.android.permission.ACCESS_FINE_LOCATION"/&gt;
      &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt;
  
      &lt;uses-feature
          android:glEsVersion="0x00020000"
          android:required="true"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;uses-library android:name="com.google.android.maps"/&gt;
          &lt;activity
              android:name=".activities.HomeActivity" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;    
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;meta-data
              android:name="com.google.android.gms.version"
              android:value="@integer/google_play_services_version" /&gt;
          &lt;meta-data
              android:name="com.google.android.maps.v2.API_KEY"
              android:value="@string/map_api_key"/&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>But I am facing this error:</p>
  
  <pre><code>Caused by: java.lang.SecurityException: The Maps API requires the additional following
  permissions to be set in the AndroidManifest.xml to ensure a correct behavior: 
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>But, as it is showed in my manifest, I have this permission. One detail is if I put only the <code>WRITE_EXTERNAL_STORAGE</code> permission, without specifying the <code>maxSdkVersion</code> value, the app works properly. </p>
  
  <p>Is this an Android bug or am I forgetting something in my app configuration?</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>This is the logcat:</p>
  
  <pre><code> FATAL EXCEPTION: main
   Process: com.example.map, PID: 15534
   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.map/com.example.map.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
      at android.app.ActivityThread.access$800(ActivityThread.java:135)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:136)
      at android.app.ActivityThread.main(ActivityThread.java:5017)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
      at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
      at android.app.Activity.setContentView(Activity.java:1929)
      at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:216)
      at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
      at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:76)
      at com.example.map.MainActivity.onCreate(MainActivity.java:16)
      at android.app.Activity.performCreate(Activity.java:5231)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
      ... 11 more
   Caused by: java.lang.SecurityException: The Maps API requires the additional following permissions to be set in the AndroidManifest.xml to ensure a correct behavior:
   &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
      at maps.e.ci.a(Unknown Source)
      at maps.e.ay.a(Unknown Source)
      at maps.e.ay.a(Unknown Source)
      at maps.e.al.a(Unknown Source)
      at maps.e.bh.a(Unknown Source)
      at maps.e.bg.a(Unknown Source)
      at etu.onTransact(SourceFile:107)
      at android.os.Binder.transact(Binder.java:361)
      at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
      at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
      at com.google.android.gms.dynamic.a$4.b(Unknown Source)
      at com.google.android.gms.dynamic.a.a(Unknown Source)
      at com.google.android.gms.dynamic.a.onCreateView(Unknown Source)
      at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1093)
      at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1195)
      at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>My layout:</p>
  
  <pre><code>&lt;fragment
      android:id="@+id/map"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      class="com.google.android.gms.maps.SupportMapFragment" /&gt;
  </code></pre>
  
  <p><strong>UPDATE 3</strong></p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  }
  </code></pre>