android - Google Places API 总是返回错误

标签 android google-places-api

我已将 Google Places API 集成到我的 android 应用程序中。 我已经阅读了 api 文档 See Here .

我已激活适用于 Android 的 Google Places Api 并生成了浏览器 key 当我调用 api 时得到响应错误 -

{"error_message" : "This API project is not authorized to use this API.Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
  "html_attributions" : [],
  "results" : [],
  "status" : "REQUEST_DENIED"
}

我也尝试创建 android key 并返回 -

{
 "error_message" : "This IP, site or mobile application is not authorized to use this API key.",
 "html_attributions" : [],
 "results" : [],
 "status" : "REQUEST_DENIED"
}

我不知道我的代码中有什么问题。

感谢任何帮助。提前致谢。

检查 API 控制台 - enter image description here

最佳答案

我遇到了同样的问题。在我的例子中,问题是我试图通过这个 url 使用简单的 HttpUrlconnection 发送请求:

 https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=62.25227243964484%2C59.12338379770518&radius=500&key=my_key

my_key 是 Google Places API for Android 的 key ,但是当我切换到 Google Places API Web Service 时,它工作正常。似乎要使用适用于 Android 的 Google Places API 的 key ,您应该遵循本指南 https://developers.google.com/places/android/

关于android - Google Places API 总是返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30044562/

相关文章:

android - Appcelerator 4 在 Mac 上找不到 Android SDK

google-maps - Google Places/Maps API - 快速事实文本?

google-maps - 无法从 Google Place Details API 获取营业时间

java - 将按钮或图像居中

Android Studio - 找不到 org.jetbrains.kotlin :kotlin-stdlib:1. 1.3-2

swift - 具有不相关托管对象上下文的 Google 地点选择器的 CoreData 线程问题

android - javax.net.ssl.SSLPeerUnverifiedException : No peer certificate while I am working with google place api in android

android - Google Places API 缺少 Place.TYPE_ADDRESS?

android - AssetManager 无法在 NDK 中运行

java - 在 ViewHolder 中保存列表项的引用是一种不好的做法吗