2017-06-17 93 views
0

搖籃相關性:NullPointerException異常而調用PlacePicker

compile "com.google.android.gms:play-services-location:11.0.0" 
compile "com.google.android.gms:play-services-places:11.0.0" 

Menifest:

<menifest> 
. 
. 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 

    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true"/> 
    <application> 
    . 
    . 
     <meta-data 
      android:name="com.google.android.geo.API_KEY" 
      android:value="@string/google_maps_key" /> 
     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 
</application> 
</menifest> 

的Java:

private void showPlacePicker() { 
     PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); 
     try { 
      startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST); 
     } catch (GooglePlayServicesRepairableException e) { 
      Log.d("PlacesAPI Demo", "GooglePlayServicesRepairableException thrown"); 
     } catch (GooglePlayServicesNotAvailableException e) { 
      Log.d("PlacesAPI Demo", "GooglePlayServicesNotAvailableException thrown"); 
     } 
    } 

我也啓用了Google Places API for Android。並且不要認爲,api密鑰集成存在問題,因爲我已經使用該密鑰加載了谷歌地圖。儘管如此,一旦調用方法showPlacePicker(),應用程序崩潰。

Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bn.o()' on a null object reference 
    at com.google.maps.api.android.lib6.impl.cw.b(:com.google.android.gms.DynamiteModulesB:26) 
    at com.google.android.gms.maps.internal.t.onTransact(:com.google.android.gms.DynamiteModulesB:21) 
    at android.os.Binder.transact(Binder.java:387) 
    at unt.b(:com.google.android.gms:1) 
    at ode.a(:com.google.android.gms:0) 
    at ocx.b(:com.google.android.gms:2) 
    at ocu.a(:com.google.android.gms:2) 
    at com.google.android.gms.maps.MapView.a(:com.google.android.gms:1) 
    at alox.onResume(:com.google.android.gms:2) 
    at com.google.android.chimera.FragmentProxy.onResume(:com.google.android.gms:0) 

回答

相關問題