gpt4 book ai didi

android - RuntimeExecutionException : com. google.android.gms.common.api.ApiException:13:错误位置 API

转载 作者:IT老高 更新时间:2023-10-28 22:17:40 24 4
gpt4 key购买 nike

我在尝试使用 google places API 来获取 Current Place 的可能位置时遇到以下异常在安卓中。

Process: me.nabeelkottol.linkedinplaces, PID: 2995
com.google.android.gms.tasks.RuntimeExecutionException:
com.google.android.gms.common.api.ApiException: 13: ERROR
at com.google.android.gms.tasks.zzn.getResult(Unknown Source)
at
me.nabeelkottol.linkedinplaces.MainActivity$1.onComplete(MainActivity.java:71)
at com.google.android.gms.tasks.zzf.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.google.android.gms.common.api.ApiException: 13: ERROR
at com.google.android.gms.common.internal.zzb.zzz(Unknown Source)
at com.google.android.gms.common.internal.zzbk.zzaa(Unknown Source)
at com.google.android.gms.common.internal.zzbl.zzs(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source)
at com.google.android.gms.location.places.zzm.zzao(Unknown Source)
at com.google.android.gms.location.places.internal.zzx.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)

这是我的代码:

try {
Task<PlaceLikelihoodBufferResponse> placeResult = mPlaceDetectionClient.getCurrentPlace(null);
placeResult.addOnCompleteListener(new OnCompleteListener<PlaceLikelihoodBufferResponse>() {
@Override public void onComplete(@NonNull Task<PlaceLikelihoodBufferResponse> task) {

PlaceLikelihoodBufferResponse likelyPlaces = task.getResult();
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Log.i(TAG,
String.format("Place '%s' has likelihood: %g", placeLikelihood.getPlace().getName(),
placeLikelihood.getLikelihood()));
}
likelyPlaces.release();

}
});
} catch (SecurityException e) {
e.printStackTrace();
}

这行 PlaceLikelihoodBufferResponse possiblePlaces = task.getResult(); 给了我错误。

我通过提供包名称和 SHA-1 key 从 Google API 控制台 进行调试,为 Android 应用程序创建了一个 API key 。并且在 libraries 部分中启用了适用于 android 的 Google Places API。仍然给出同样的错误。不知道实现有什么问题。请帮帮我。

有一个 issue在 github 上报告了这一点。

这是我的 app/build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "me.nabeelkottol.linkedinplaces"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.android.gms:play-services-places:11.6.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

这是我的 AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.nabeelkottol.linkedinplaces">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="My API Key here"/>

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>

最佳答案

在 list 中添加以下代码

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

关于android - RuntimeExecutionException : com. google.android.gms.common.api.ApiException:13:错误位置 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47279161/

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