Google 指示 returns REQUEST_DENIED 从 Android 呼叫时

Google directions returns REQUEST_DENIED when called from Android

我正在向 Google Directions 发送一个 HTTP 请求,并且我不断从我的 Android 应用中获取 REQUEST_DENIED。我已经检查了我在 Google 控制台的 API 键中配置的 SHA-1,并确保为我的项目启用了方向 API。我错过了什么吗?

检查您在 android 应用程序中使用的 api 密钥是否不受限制Google 地图方向不支持 android 受限键,仅支持 IP 地址限制(您不能对 android 应用程序执行此操作)

来自文档:

Google Maps APIs are available via HTTP web services, for web browsers, and Android or iOS apps. APIs in any platform can use a generic (unrestricted) API key. You can optionally add a restriction (for example, IP addresses) to the API key. Once restricted, a key will only work on platforms that support that type of restriction.

Tip: Before moving your app or website to production, you should secure your API key. Keys for the Google Maps Directions API use the IP addresses (web servers, cron jobs, etc.) key restriction