0

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.

user695752
  • 319
  • 7
  • 18
  • 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. –  Jan 11 '21 at 03:35
  • This can help you, [How do I draw a route, along an existing road, between two points?](https://stackoverflow.com/questions/47492459/how-do-i-draw-a-route-along-an-existing-road-between-two-points) – rahat Jan 11 '21 at 04:58

2 Answers2

1

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

Rezaul Karim
  • 830
  • 8
  • 15
0

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.

Hari
  • 1