Place Picker Automatically close after launch

23,009

Solution 1

After A lot of debugging i solved it myself. The problem was package name..Android studio manage package name by itself on project creation. I change the package name in manifest and it was working perfectly fine. but when i get API key from google developers console for place picker, place picker automatically closes without a single character of error.

Then I change the package name by going into -> Module Settings -> Flavors and change the Application ID and it fix the problem.

Solution 2

Please check the logcat of your app for 'PLACES_API_ACCESS_NOT_CONFIGURED' message. If this is the case, enabling the Google Places API for Android in your Google Developer Console for this project should solve your problem.

Solution 3

Make sure that Google Places API is enabled for the API key that you are using in Google API console. For me, I am using the same API key that I use for maps. I just enabled the same key for places api also. That solved my problem. Use this link to access the Google console: https://console.developers.google.com/flows/enableapi?apiid=placesandroid&reusekey=true

Solution 4

Solved problem by just changing the API key

You can create a new key from here

Solution 5

Instead of enabling the places API, Enable the places SDK for android. Worked for me. Good Luck :)

Share:
23,009
Zeeshan Ahmed
Author by

Zeeshan Ahmed

Salesforce.com Certified Developer/Consultant with extensive experience in CRM & BPM consulting and demonstrated success in implementing and customizing several CRM packages for different industries.

Updated on March 20, 2020

Comments

  • Zeeshan Ahmed
    Zeeshan Ahmed about 4 years

    I want to show place picker so that user can choose location of his/her own choice. But place picker child activity automatically closes after launch. I've check the API key multiple times and other permissions, everything is correct. Here is all the code. Please help!

    task_location.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
                    Intent intent = intentBuilder.build(NewTaskActivity.this);
                    // Start the Intent by requesting a result, identified by a request code.
                    startActivityForResult(intent, 123);
    
    
                } catch (GooglePlayServicesRepairableException e) {
                    GooglePlayServicesUtil
                            .getErrorDialog(e.getConnectionStatusCode(), NewTaskActivity.this, 0);
                } catch (GooglePlayServicesNotAvailableException e) {
                    Toast.makeText(NewTaskActivity.this, "Google Play Services is not available.",
                            Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
    

    And here is the menifest file.

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="android:icon">
    
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="AIzaSyAjM9hWUXm8vlABqFbM_fJfQgIFli8HP1E"/>
    
  • Katedral Pillon
    Katedral Pillon over 8 years
    How do you get to Module Settings?
  • Zeeshan Ahmed
    Zeeshan Ahmed over 8 years
    Right Click on your project, and click the second last option from the list. e.g Module Settings OR simply press F4.
  • Ninja
    Ninja almost 7 years
    Thanks, Its worked for me after i enableGoogle Places API Web Service API in Google Api developer console
  • Rajbir Shienh
    Rajbir Shienh almost 6 years
    Thanks, couldn't find the problem for at least a few hours.
  • Vaisakh N
    Vaisakh N over 5 years
    Thanks @ZeeshanAhmed. I
  • Mehul Tank
    Mehul Tank about 5 years
    i am getting same issue i had enable place api already but getting still issue is there any solution?