gpt4 book ai didi

android - 无法连接到 Google API 客户端

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:59:44 25 4
gpt4 key购买 nike

我无法获取最后的已知位置。我在 Google 控制台中启用了 Geocoding APIGoogle Places API for Android。我将 api key 添加到 list 文件:

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_api_key" />

但我不断在控制台中收到一条消息:“无法连接到 Google API 客户端:ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}


更新

I use google sample

protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}

@Override
public void onConnected(Bundle connectionHint) {
Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
mGoogleApiClient);
if (mLastLocation != null) {
Toast.makeText(this, "Latitude = " + mLastLocation.getLatitude() + "\n" +
"Longitude = " + mLastLocation.getLongitude(), Toast.LENGTH_LONG).show();
}
}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Toast.makeText(this, connectionResult.toString(), Toast.LENGTH_LONG).show();
}

onConnectedonConnectionFailed 不调用。

我也用 Android-ReactiveLocation但两种方法都输出到控制台:Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}

最佳答案

我遇到了同样的问题

Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}

因为 Google Places API for Android 未在 API 控制台中启用。

https://developers.google.com/places/android/signup

关于android - 无法连接到 Google API 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30650231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com