title: Google Maps Force Close in API 17
body: <p>I am trying to make a simple map application in navigation drawer (using Android Studio) but I am facing a weird case. I tried in Virtual Device API 24 (also real Marshmallow device) and it works fine (no error message in log cat).</p>
  
  <p>But when I tried in Virtual Device API 17 (also real Kitkat 4.4.2 device), the application throws an error.</p>
  
  <p>LocationFragment.java</p>
  
  <pre><code>package dev.dtgultom.ontelbike.Fragment;
  
  import android.app.Fragment;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import com.google.android.gms.maps.CameraUpdateFactory;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.MapFragment;
  import com.google.android.gms.maps.OnMapReadyCallback;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  
  import dev.dtgultom.ontelbike.R;
  
  public class LocationFragment extends Fragment implements OnMapReadyCallback {
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_location,container,false);
          return view;
      }
  
      @Override
      public void onViewCreated(View view, Bundle savedInstanceState) {
          super.onViewCreated(view, savedInstanceState);
          MapFragment fragment = (MapFragment) getChildFragmentManager().findFragmentById(R.id.map);
          fragment.getMapAsync(this);
      }
  
      @Override
      public void onMapReady(GoogleMap googleMap) {
          LatLng stockholm = new LatLng(59.3293, 18.0686);
          googleMap.addMarker(new MarkerOptions().position(stockholm).title("User Position"));
          googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(stockholm, 15));
      }
  }
  </code></pre>
  
  <p>fragment_location.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  
      &lt;fragment
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"
          tools:context="dev.dtgultom.ontelbike.Fragment.LocationFragment"/&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>AndroidManifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="dev.dtgultom.ontelbike"&gt;
  
      &lt;uses-feature
          android:glEsVersion="0x00020000"
          android:required="true" /&gt;
  
      &lt;!-- To auto-complete the email text field in the login form with the user's emails --&gt;
      &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt;
      &lt;uses-permission android:name="android.permission.READ_PROFILE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".SplashScreen"&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;activity
              android:name=".LoginActivity"
              android:label="@string/title_activity_login" /&gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/title_activity_main"
              android:theme="@style/AppTheme.NoActionBar"/&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.geo.API_KEY"
              android:value="@string/api_key" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>build.gradle</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 26
      buildToolsVersion "26.0.1"
      defaultConfig {
          applicationId "dev.dtgultom.ontelbike"
          minSdkVersion 17
          targetSdkVersion 26
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          vectorDrawables.useSupportLibrary = true
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      productFlavors {
      }
  }
  
  dependencies {
      compile fileTree(include: ['*.jar'], dir: 'libs')
      androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
      compile 'com.android.support:appcompat-v7:26.+'
      compile 'com.android.support.constraint:constraint-layout:1.0.2'
      compile 'com.android.support:support-v4:26.+'
      compile 'com.android.support:support-vector-drawable:26.+'
      compile 'com.android.support:design:26.+'
      compile 'com.google.android.gms:play-services-maps:11.0.4'
      compile 'com.google.android.gms:play-services-location:11.0.4'
      testCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>logcat when testing in virtual device API 17</p>
  
  <pre><code>09-01 13:38:27.327 23397-23397/dev.dtgultom.ontelbike E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
  09-01 13:39:49.043 23397-23397/dev.dtgultom.ontelbike W/dalvikvm: VFY: unable to resolve check-cast 34 (Landroid/app/AppOpsManager;) in Lcom/google/android/gms/internal/zzbgz;
  09-01 13:39:49.043 23397-23397/dev.dtgultom.ontelbike D/dalvikvm: VFY: replacing opcode 0x1f at 0x0010
  09-01 13:39:49.047 23397-23397/dev.dtgultom.ontelbike I/zzbx: Making Creator dynamically
  09-01 13:39:49.191 23397-23397/dev.dtgultom.ontelbike E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          java.lang.NullPointerException
                                                                              at dev.dtgultom.ontelbike.Fragment.LocationFragment.onViewCreated(LocationFragment.java:29)
                                                                              at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:899)
                                                                              at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
                                                                              at android.app.BackStackRecord.run(BackStackRecord.java:682)
                                                                              at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
                                                                              at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441)
                                                                              at android.os.Handler.handleCallback(Handler.java:725)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                              at android.os.Looper.loop(Looper.java:137)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5041)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:511)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                                                                              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I already tried the solution in:</p>
  
  <pre><code>https://stackoverflow.com/questions/29655172/google-maps-api-v2-android-error
  https://stackoverflow.com/questions/30991087/mapfragment-getmapasyncthis-nullpointerexception
  https://stackoverflow.com/questions/28109206/null-pointer-exception-at-mapfragment-getmapasyncthis-while-initializing-googl
  https://stackoverflow.com/questions/30991087/mapfragment-getmapasyncthis-nullpointerexception
  https://stackoverflow.com/questions/26340398/java-lang-nullpointerexception-with-android-fragment
  </code></pre>
  
  <p>But it is not working.  It works fine in my real Marshmallow device and virtual device API 24 and the error occur in my real kitkat (4.4.2) device and virtual device API 17.</p>