0
votes

I am trying to run the following example to display route directions between two locations on Google Map.

https://www.wingsquare.com/blog/drawing-driving-route-directions-between-two-locations-using-google-directions-in-google-map-android/

However, I keep getting the following error in Android Studio run tab when I click on the map to create two markers:

DownloadTask : { "error_message" : "This API project is not authorized to use this API.", "routes" : [], "status" : "REQUEST_DENIED"}

Also, a toast message shows "No route found".

I have the following APIs enabled in Google Developers Console:

  • Maps SDK for Android
  • Directions API
  • Distance Matrix API
  • Geocoding API
  • Maps Embed API
  • Maps JavaScript API
  • Places API

However, the error message doesn't seem to have changed between enabling each of the APIs.

2
Did you create your own API key and update the google_maps_api.xml file? The example does not include an API key. Note you can test the URL (with API key) in a web browser to eliminate the app from the investigation.Andy

2 Answers

1
votes

Once i face the same problem. Then i check the google account for map sdk. There i found that my account was not added with some payment options. Direction API requires payment method. And finally check that you put correct api key in google_maps_api.xml

0
votes

I've had this problem, just ensure that you have enabled the directions api. You need both the sdk for android/ios and the directions api enabled to get it to work.