0

我正在尝试在我的 android 中从 Google 地图中查找位置,我的代码是

PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
            getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

    autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            // TODO: Get info about the selected place.
            Log.i(TAG, "Place: " + place.getName());

            String placeDetailsStr = place.getName() + "\n"
                    + place.getId() + "\n"
                    + place.getLatLng().toString() + "\n"
                    + place.getAddress() + "\n"
                    + place.getAttributions();
        }

        @Override
        public void onError(Status status) {
            // TODO: Handle the error.
            Log.i(TAG, "An error occurred: " + status);
        }
    });

但是当我尝试输入某些内容时,它会因错误而崩溃

FATAL EXCEPTION: main                                                    Process: com.example.asset.lab13_bonus, PID: 1192
                                                                         java.lang.NoSuchMethodError: No virtual method zzbo(Landroid/content/Context;)V in class Lcom/google/android/gms/common/GoogleApiAvailability; or its super classes (declaration of 'com.google.android.gms.common.GoogleApiAvailability' appears in /data/app/com.example.asset.lab13_bonus-bAk1S6P8t8HToIo1FR8JeA==/split_lib_dependencies_apk.apk:classes12.dex)
                                                                             at com.google.android.gms.location.places.ui.zza$zza.build(Unknown Source:79)
                                                                             at com.google.android.gms.location.places.ui.PlaceAutocomplete$IntentBuilder.build(Unknown Source:0)
                                                                             at com.google.android.gms.location.places.ui.PlaceAutocompleteFragment.zzboi(Unknown Source:42)
                                                                             at com.google.android.gms.location.places.ui.PlaceAutocompleteFragment.zza(Unknown Source:0)
                                                                             at com.google.android.gms.location.places.ui.PlaceAutocompleteFragment$1.onClick(Unknown Source:2)
                                                                             at android.view.View.performClick(View.java:6256)
                                                                             at android.view.View$PerformClick.run(View.java:24697)
                                                                             at android.os.Handler.handleCallback(Handler.java:789)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                             at android.os.Looper.loop(Looper.java:164)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

摇篮依赖:

compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-places:9.4.0'
compile "com.google.android.gms:play-services-base:9.4.0"

这是什么意思 ?有人能帮我吗?可能是因为设备的原因它不起作用?

4

2 回答 2

3

尝试这个,

compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-places:9.4.0'
compile "com.google.android.gms:play-services-base:9.4.0"
于 2017-11-14T10:44:25.180 回答
1

尝试确保所有依赖项都是相同的版本以避免冲突,无论是 9.4.0 还是 11.0.4。旧版本可以正常工作,但您可能会错过新版本提供的某些功能。

于 2017-11-16T06:08:28.120 回答