title: Weird SupportMapFragment behaviour
body: <p>If we use our native library using <code>System.loadLibrary()</code> then <code>SupportMapFragment</code> just kills <code>activity</code> after few seconds when it's launched. And it does that without any stacktrace. This is the best log I could collect:</p>
  
  <pre><code>06-10 02:10:01.063 22787-23766/com.myapp.staging E/DynamiteModule: Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.android.gms.googlecertificates.ModuleDescriptor" on path: DexPathList[[zip file "/data/app/com.myapp.staging-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.staging-1/lib/arm, /data/app/com.myapp.staging-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
  06-10 02:10:01.063 22787-23766/com.myapp.staging W/ResourcesManager: getTopLevelResources: /data/app/com.google.android.gms-1/base.apk / 1.0 running in com.myapp.staging rsrc of package com.google.android.gms
  06-10 02:10:01.063 22787-23766/com.myapp.staging I/DynamiteModule: Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:1
  06-10 02:10:01.063 22787-23766/com.myapp.staging I/DynamiteModule: Selected remote version of com.google.android.gms.googlecertificates, version &gt;= 1
  06-10 02:10:01.153 23793-23793/? I/dex2oat: /system/bin/dex2oat --debuggable --compiler-filter=speed --dex-file=/data/user/0/com.google.android.gms/app_chimera/m/00000000/DynamiteModulesA_GmsCore_prodmnc_alldpi_release.apk --oat-file=/data/dalvik-cache/arm/data@user@0@com.google.android.gms@app_chimera@m@00000000@DynamiteModulesA_GmsCore_prodmnc_alldpi_release.apk@classes.dex
  06-10 02:10:01.153 23793-23793/? E/dex2oat: Failed to create oat file: /data/dalvik-cache/arm/data@user@0@com.google.android.gms@app_chimera@m@00000000@DynamiteModulesA_GmsCore_prodmnc_alldpi_release.apk@classes.dex: Permission denied
  06-10 02:10:01.153 23793-23793/? I/dex2oat: dex2oat took 721.250us (threads: 4) 
  06-10 02:10:01.153 5853-5853/? E/audit: type=1701 msg=audit(1465506601.153:5185): auid=4294967295 uid=10329 gid=10329 ses=4294967295 subj=u:r:untrusted_app:s0:c512,c768 pid=23766 comm="androidmapsapi-" reason="memory violation" sig=11
  06-10 02:10:01.153 3542-4463/? D/libgps: OnGpsExtensionMessage: message_id(1), data(0x7f95455e44), size(2432)
  06-10 02:10:01.153 3542-4463/? D/libgps: GpsiHook: API: gpsSvStatusCb(GpsiHookStateGps: e,c,g)
  06-10 02:10:01.153 3542-4463/? D/libgps: proxy__gps_sv_status_cb : called
  06-10 02:10:01.173 3542-3607/? I/PassiveLocTracker: GPS Satllite Status
  06-10 02:10:01.243 3542-4368/? I/WindowState: WIN DEATH: Window{ae4e596 u0 d0 com.myapp.staging/com.myapp.ui.activity.FrameActivity}
  06-10 02:10:01.243 3067-4605/? D/libEGL: eglTerminate EGLDisplay = 0x7f6bae1f88
  06-10 02:10:01.243 3067-4605/? D/libEGL: eglTerminate EGLDisplay = 0x7f6bae1f88
  06-10 02:10:01.243 3542-4286/? D/GraphicsStats: Buffer count: 21
  06-10 02:10:01.253 3542-4368/? D/InputDispatcher: Focus left window: 22787
  06-10 02:10:01.253 3542-4639/? I/AppOps: sendInfoToFLP, code=41 , uid=10329 , packageName=com.myapp.staging , type=finishOp
  06-10 02:10:01.253 3542-4120/? I/ActivityManager: Process com.myapp.staging (pid 22787)(adj 0) has died(114,1020)
  06-10 02:10:01.253 3542-3564/? I/WindowState: WIN DEATH: Window{6ba02d0 u0 d0 com.myapp.staging/com.myapp.ui.activity.VisitActivity}
  06-10 02:10:01.253 3542-4227/? I/AppOps: sendInfoToFLP, code=42 , uid=10329 , packageName=com.myapp.staging , type=finishOp
  06-10 02:10:01.263 3542-4120/? D/ActivityManager: isAutoRunBlockedApp:: com.myapp.staging, Auto Run ON
  06-10 02:10:01.263 3542-4120/? W/ActivityManager: Force removing ActivityRecord{6796427 u0 com.myapp.staging/com.myapp.ui.activity.FrameActivity t5324}: app died, no saved state
  </code></pre>
  
  <p>I have spent few days trying to understand what was causing it and it seems if we remove <code>System.loadLibrary()</code> call i.e. not use our native lib then <code>SupportMapFragment</code> works fine. Is there any way I can resolve it without removing our native lib?</p>
  
  <p><strong>EDIT:</strong>
  I created a sample app to reproduce this issue and after the above mentioned log I also got something which seems useful:</p>
  
  <pre><code>06-14 13:17:28.415 5756-5756/? E/audit: type=1701 msg=audit(1465892248.405:4500): auid=4294967295 uid=10332 gid=10332 ses=4294967295 subj=u:r:untrusted_app:s0:c512,c768 pid=6431 comm="androidmapsapi-" reason="memory violation" sig=11
  </code></pre>
  
  <p><strong>EDIT2:</strong></p>
  
  <p><em>MapsActivity.java</em></p>
  
  <pre><code>public class MapsActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Go.init(this);
      setContentView(R.layout.activity_maps);
  }
  
  public void showMap(View view) {
      getSupportFragmentManager().beginTransaction().replace(R.id.container, new MapFragment()).commit();
  }
  }
  </code></pre>
  
  <p><em>MapFragment.java</em></p>
  
  <pre><code>public class MapFragment extends android.support.v4.app.Fragment implements OnMapReadyCallback {
  
  private GoogleMap mMap;
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      return inflater.inflate(R.layout.map_frag, null, false);
  }
  
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager()
              .findFragmentById(R.id.maps);
      mapFragment.getMapAsync(this);
  
  }
  
  @Override
  public void onMapReady(GoogleMap googleMap) {
      mMap = googleMap;
  
      // Add a marker in Sydney and move the camera
      LatLng sydney = new LatLng(-34, 151);
      mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
      mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
  }
  }
  </code></pre>
  
  <p><em>Go.java</em></p>
  
  <pre><code>public final class Go {
  // init loads libgojni.so and starts the runtime.
  public static void init(final Context ctx) {
      if (Looper.myLooper() != Looper.getMainLooper()) {
          Log.wtf("Go", "Go.init must be called from main thread (thread="+Thread.currentThread().getName()+")");
      }
      if (running) {
          return;
      }
      running = true;
  
      // TODO(crawshaw): context.registerComponentCallbacks for runtime.GC
  
      System.loadLibrary("gojni");
      Go.run(ctx);
      new Thread("GoReceive") {
          public void run() { Seq.receive(); }
      }.start();
  }
  
  private static boolean running = false;
  
  private static native void run(Context ctx);
  }
  </code></pre>
  
  <p>This is the folder structure:</p>
  
  <p><a href="https://i.stack.imgur.com/BY9Em.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BY9Em.png" alt="enter image description here"></a></p>