1

I'm using Google Maps API and Direction API in my android app. When I compile it, it gives me the following error for the function onRoutingFaliure.

This IP, site or mobile application is not authorized to use this API key. Request received from IP address XX.XX.XX.XX, with empty referer

public void onRoutingFailure(RouteException e) {
        if(e != null) {
            Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
        }else {
            Toast.makeText(this, "Something went wrong, Try again", Toast.LENGTH_SHORT).show();
        }
    }

How can I resolve this?

Poo
  • 143
  • 4
  • 19
  • 1
    Have you enabled API for root? – MMG Apr 25 '20 at 11:29
  • I have enabled it at the API library. I don't know what you mean as "enable API for root". Do I have something more to do? – Poo Apr 25 '20 at 11:33
  • https://console.developers.google.com/apis/library – MMG Apr 25 '20 at 11:38
  • Yes, I have enabled the API there. – Poo Apr 25 '20 at 11:40
  • Are you using correct package ID and correct SHA in Google Console? – Boken Apr 25 '20 at 12:02
  • Yes, I have two users(driver, parent) in this app and I get the driver location through firebase and it is shown in the map with parent location. That works totally fine. Now I want to add the route between these two. At this moment I'm getting the error. Up to that, all are fine. – Poo Apr 25 '20 at 12:08
  • 1
    Directions API is a web service so you cannot use the same Android-restricted API key you use for Maps SDK for Android. Please check out https://stackoverflow.com/a/57229885/11742502 – evan Apr 29 '20 at 08:51

0 Answers0