0

I am adding Google Places to my App, The Google Fragment works and opens but once I begin to Type a test it it closes automatically. I have done everything online to try and fix it. Make new API, restrict the API and link the API to my App

I just get the Error code from Google OnError as

Status{statusCode=This IP, site or mobile application is not authorized to use this API key. Request received from IP address 37.228.239.82, with empty referrer, resolution=null} "

I'm Stuck to try figure out what steps to do now, there's not much I haven't done

I'm using Android Studio with everything up to date including the Places dependencies.

Places.initialize(applicationContext,PlacesAPIKey)
val placesClient = Places.createClient(this)

if (Places.isInitialized()) {
    val autocompleteFragment =
        supportFragmentManager.findFragmentById(R.id.autocomplete_fragment)
                as AutocompleteSupportFragment

    autocompleteFragment.setTypeFilter(TypeFilter.REGIONS)

    autocompleteFragment.setPlaceFields(listOf(Place.Field.ID, Place.Field.NAME))


    autocompleteFragment.setOnPlaceSelectedListener(object : PlaceSelectionListener {
        override fun onPlaceSelected(place: Place) {
            Log.d("Place", "${place.name}, ${place.id}")

        }
        override fun onError(p0: Status) {
            Log.d("PlacesError","$p0")
        }
    })
}else{
 Log.d("PlacesNotWorking","Not Initalized")
}
        

Image of Google API without Restrictions

João Dias
  • 16,277
  • 6
  • 33
  • 45

1 Answers1

0

I solved Issue, If anyone comes across this

autocompleteFragment.setTypeFilter(TypeFilter.REGIONS)

was causing the error even with restrictions set to none and App link with Package name and Sha-1.