title: VectorDrawable with GoogleMap BitmapDescriptor
body: <p>I have problem with google maps <code>BitmapDescriptor</code> while creating icon for <code>MarkerOptions</code> using <code>VectorDrawable</code>, API 5.0+</p>
  
  <p>Method used for creation:</p>
  
  <pre><code>@NonNull
  private BitmapDescriptor getBitmapDescriptor(int id) {
      return BitmapDescriptorFactory.fromResource(id);
  }
  </code></pre>
  
  <p>Everything works great when <code>id</code> argument contains png drawable, however if I try it with <code>VectorDrawable</code> defined in xml, App always crash when <code>googleMap.addMarker(marker)</code> (<code>BitmapDescriptor</code> is not null).</p>
  
  <pre><code>11-05 10:15:05.213 14536-14536/xxx.xxxxx.app E/AndroidRuntime: FATAL EXCEPTION: main
      Process: xxx.xxxxx.app, PID: 14536
      java.lang.NullPointerException
          at com.google.a.a.ae.a(Unknown Source)
          at com.google.maps.api.android.lib6.d.dn.&lt;init&gt;(Unknown Source)
          at com.google.maps.api.android.lib6.d.dm.a(Unknown Source)
          at com.google.maps.api.android.lib6.d.ag.&lt;init&gt;(Unknown Source)
          at com.google.maps.api.android.lib6.d.eu.a(Unknown Source)
          at com.google.android.gms.maps.internal.j.onTransact(SourceFile:167)
          at android.os.Binder.transact(Binder.java:380)
          at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.addMarker(Unknown Source)
          at com.google.android.gms.maps.GoogleMap.addMarker(Unknown Source)
          at xxx.xxxxx.app.ui.details.DetailActivity.lambda$initGoogleMaps$23(DetailActivity.java:387)
          at xxx.xxxxx.app.ui.details.DetailActivity.access$lambda$10(DetailActivity.java)
          at xxx.xxxxx.app.ui.details.DetailActivity$$Lambda$13.onMapReady(Unknown Source)
          at com.google.android.gms.maps.SupportMapFragment$zza$1.zza(Unknown Source)
          at com.google.android.gms.maps.internal.zzl$zza.onTransact(Unknown Source)
          at android.os.Binder.transact(Binder.java:380)
          at com.google.android.gms.maps.internal.av.a(SourceFile:82)
          at com.google.maps.api.android.lib6.d.fa.run(Unknown Source)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:135)
          at android.app.ActivityThread.main(ActivityThread.java:5221)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  </code></pre>
  
  <p>It doesn't matter how i retrieve drawable, tried creating bitmap using <code>BitmapFactory.fromResources</code> and later <code>BitmapDescritpionFactory.fromBitmap</code> but results are the same. It just won't work with vector drawable. Tried different vectors as well but it's seems that vector complexity is not the issue here.</p>
  
  <p>Does anyone know how to fix this crash?</p>
  
  <p>@edit</p>
  
  <p>It seems like the problem wasn't with the <code>BitmapDescriptior</code> itself, but rather with loading <code>VectorDrawable</code> which was returning incorrect bitmap. However solution proposed in answer is still fine.</p>