I enabled Google Places API for Android in google console and put the API key in manifest file

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key" />

in my activity

 PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        Intent intent = builder.build(KhetAdd.this);
        startActivityForResult(intent, PLACE_PICKER_REQUEST_CODE);

and

 @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == PLACE_PICKER_REQUEST_CODE) {
            final Place place = PlacePicker.getPlace(this, data);
            final CharSequence name = place.getName();
            final CharSequence address = place.getAddress();
}}}

This code is perfectly working in my android studio but when i am compiling this same code in other android studio, after launching immediately map is closing. Why is that ? Please help me out.

2

There are 2 answers

1
Rajesh On

https://console.developers.google.com/

Select project -> Dashboard -> Enable API -> Google Maps APIs

Google Maps Android API

Google Places API for Android and Google Maps Geocoding API - Enable this

wait a minute to reflect,

Restart your app, Enjoy ;)

0
Nilam Vaddoriya On

I got your issue, issue is regarding authentication.So You need to add SHA fingerprint for each android app on your project settings on google developer console.

https://console.developers.google.com/