首页 > 解决方案 > android studio中的API认证问题

问题描述

我是 Android Studio - Java 的初学者。我正在开发 Android 应用程序,将汽车动画显示为 Uber,当我尝试在 url 显示的模拟器中运行汽车动画时遇到问题

   "error_message" : "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account",
   "routes" : [],
   "status" : "REQUEST_DENIED"
}

我创建了一个 API 帐户并激活了计费帐户。此外,我将 API 密钥限制为 API 方向..

我的代码..

 requestUrl = "https://maps.googleapis.com/maps/api/directions/json?"+
                   "mode=driving&"+
                   "transit_routing_preference=less_driving&"+"origin=-33.92873%2C18.458879&destination=-33.92873%2C18.458879&waypoints=-33.9403%2C18.666731"+
                   "key="+getResources().getString(R.string.google_directions_key);

            Log.d("URL",requestUrl);//Print url to review by Chrome
            Log.d("The destination is : ", destination);

我还使用了(服务器密钥(由 Firebase 自动创建))..

我搜索并尝试解决这个问题,但我不能,所有的解决方案都给我相同的结果..你能帮我解决这个问题吗?谢谢 ..

标签: javaapiandroid-studioapi-key

解决方案


推荐阅读