Android Google Place API 错误状态{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED,resolution=null}

标签 android google-places-api google-places placeautocompletefragment

您好,我遇到了 Google Place API 错误

Status{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED, resolution=null}

根据 Google 新政策“弃用通知:Android 版 Places SDK 的 Google Play 服务版本”

Notice: The Google Play Services version of the Places SDK for Android (in Google Play Services 16.0.0) is deprecated as of January 29, 2019, and will be turned off on July 29, 2019. A new version of the Places SDK for Android is now available. We recommend updating to the new version as soon as possible. For details, see the migration guide. Google Place Autocomplete

我的安卓代码

<meta-data android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyBQzpD8_pXzixi7_bUfQVMgvfF0QBxinM0"/>

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

    AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder().setTypeFilter(AutocompleteFilter.TYPE_FILTER_CITIES).build();

    placeAutocompleteFragment.setFilter(autocompleteFilter);

    placeAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
        @Override
        public void onPlaceSelected(Place place) {
            Toast.makeText(getApplicationContext(),place.getName().toString(),Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onError(Status status) {
            System.out.println("apierror   "+status.toString());
            Toast.makeText(getApplicationContext(),status.toString(),Toast.LENGTH_SHORT).show();
        }
    });

日志猫

2019-03-15 11:56:53.778 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid I/System.out: apierror Status{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED, resolution=null} 2019-03-15 11:56:53.814 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@1326f91[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 2019-03-15 11:56:53.814 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@1326f91[MainActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 543796078080} 2019-03-15 11:56:53.814 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/SEM_CLIP_SemClipboardManager: isCocktailBarDisplayed : false 2019-03-15 11:56:53.815 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@7b271e1 nm : com.manish.velmurugan.googleautocompleteplacesandroid ic=null 2019-03-15 11:56:53.815 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 2019-03-15 11:56:53.819 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/InputTransport: Input channel constructed: fd=68 2019-03-15 11:56:53.825 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: ThreadedRenderer.create() translucent=true 2019-03-15 11:56:53.830 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/InputTransport: Input channel constructed: fd=70 2019-03-15 11:56:53.831 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: setView = android.widget.LinearLayout{9034b1d V.E...... ......I. 0,0-0,0} touchMode=true 2019-03-15 11:56:53.841 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: dispatchAttachedToWindow 2019-03-15 11:56:53.875 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[115,1980][1324,2304] result=0x27 surface={isValid=true 543267962880} surfaceGenerationChanged=true 2019-03-15 11:56:53.875 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: mHardwareRenderer.initialize() mSurface={isValid=true 543267962880} hwInitialized=true 2019-03-15 11:56:53.878 17418-17433/com.manish.velmurugan.googleautocompleteplacesandroid D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1209x324]-format:1 2019-03-15 11:56:53.878 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 2019-03-15 11:56:53.898 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@1326f91[MainActivity]: MSG_RESIZED: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1 2019-03-15 11:56:55.825 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: mHardwareRenderer.destroy()#4 2019-03-15 11:56:55.826 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/ViewRootImpl@eace7f4[Toast]: dispatchDetachedFromWindow 2019-03-15 11:56:55.846 17418-17418/com.manish.velmurugan.googleautocompleteplacesandroid D/InputTransport: Input channel destroyed: fd=70

>

what is the alternative to achive this task "Place Autocomplete"

This question is not duplicate Stackoverflow question becouse this question is asked 3 year before for now.

最佳答案

我将解决有关 google place API 的问题,我创建了 GitHub 公共(public)存储库来模拟 Google Place API

GitHub Repository

关于Android Google Place API 错误状态{statusCode=PLACES_API_ACCESS_NOT_CONFIGURED,resolution=null},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55176965/

相关文章:

android - 从我的 android 应用程序查询 google places api 时请求被拒绝

java - NetBeans w/Gradle 支持测试系统环境

python - 递归使用带有 python 3.5 的请求时出错(GooglePlaces API)

reactjs - Material UI - Google map 自动完成 - 仅限于城市和州?

swift3 - 在 Swift 3 中单击 textField 时在 tableView 上搜索 Google Places?

android - 添加适用于 Android 的 google place sdk 时出错[原因 : duplicate entry: com/bumptech/glide/GeneratedAppGlideModule. 类]

java - 正则表达式验证因手机号码的以下需求而失败

java - Chrome CustomTab 错误 : java. lang.NoSuchMethodError: No static method startActivity

android - 数据传输时出现未知主机异常

android - 如何在android中的子 Activity 中添加tabHost?