调用 PlacePicker 时出现 NullPointerException

NullPointerException while invoking PlacePicker

Gradle 依赖关系:

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

清单:

<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 键集成有问题,因为我使用该键加载了 google 地图。尽管如此,只要调用方法 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)

public 问题跟踪器中似乎报告了此问题:

https://issuetracker.google.com/issues/35829218

随时为问题加注星标以添加您的投票并订阅 Google 的进一步更新。