我正在尝试在我的应用中使用Places API。即使启用了Api,我的Logcat仍然会给我这两个错误:
03-17 05:31:34.777 2759-3241/com.google.android.gms.persistent E/Volley:
[158] BasicNetwork.performRequest: Unexpected response code 403 for
https://www.googleapis.com/placesandroid/v1/getAutocompletePredictions?
key=<api key>
03-17 05:31:34.782 2759-7906/com.google.android.gms.persistent E/Places:
Places API for Android does not seem to be enabled for your app. See
https://developers.google.com/places/android/signup for more details.
我尝试添加
implementation 'com.google.android.libraries.places:places-compat:1.0.0'
和
implementation 'com.google.android.libraries.places:places:1.0.0'
,但似乎都没有帮助。我可以搜索位置,但是当我在搜索栏中键入内容时,出现“ Places_Api_Access_Not_Configured”错误。我的Api仪表板显示有活动,所以我不确定是什么问题。
这就是我目前的依赖状况
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
//implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.libraries.places:places-compat:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'org.webjars.npm:debug:4.1.0'
//implementation 'com.google.firebase:firebase-admin:6.7.0'
//implementation 'com.firebase:geofire-android:2.1.1'
implementation 'com.google.gms:google-services:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
有时它们是缓存问题。 尝试删除API密钥,然后重新创建。确保您没有限制API密钥。
仅在密钥正常工作后应用限制。请注意,您可能需要等待5分钟才能使用新密钥。
使用Google Places API for Web时,您还需要启用Google Maps JavaScript API。
答案 1 :(得分:0)