Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException: Places must be initialized. #15

Closed
qasimabdani opened this issue May 9, 2019 · 4 comments
Closed

java.lang.IllegalStateException: Places must be initialized. #15

qasimabdani opened this issue May 9, 2019 · 4 comments

Comments

@qasimabdani
Copy link

qasimabdani commented May 9, 2019

Firebase Crashes Report:

Caused by java.lang.IllegalStateException
Places must be initialized.

Fatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{com.islamuna.ramadan/com.google.android.libraries.places.widget.AutocompleteActivity}: java.lang.IllegalStateException: Places must be initialized.

SDK version:
implementation 'com.google.android.libraries.places:places:1.1.0'

Layout include


<fragment
                    android:id="@+id/place_autocomplete_fragment"
                    android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/border_filled" />

Even i initialize Place sample code:

Places.initialize(getApplicationContext(), "mykey", Locale.US);

autocompleteFragment = (AutocompleteSupportFragment)
                    getSupportFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
            autocompleteFragment.setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.NAME,Place.Field.LAT_LNG));
            autocompleteFragment.setText(Global.getStoredStringValue(getApplicationContext(), getString(R.string.KEY_CITY)));

            autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
                @Override
                public void onPlaceSelected(Place place) {
                    try {

                        }
                    } catch (Exception e) {
                    }

                }

                @Override
                public void onError(Status status) {
                    // TODO: Handle the error.

                }
            });
@qasimabdani qasimabdani changed the title Android Intent expected to contain a Place, but doesn't java.lang.IllegalStateException: Places must be initialized. May 9, 2019
@linhlpv
Copy link

linhlpv commented May 10, 2019

Did you init the PlacesClient? This is maybe the reason for your issues.

@amuramoto
Copy link
Contributor

Are you initializing places in the onCreate?

@qasimabdani
Copy link
Author

Are you initializing places in the onCreate?

by mistake i close this issue.. It is still valid...
I did not initialize Place client because am not using instant of it

secondly i initializing places in the onCreate? Yes

@sholleyonline
Copy link

I experience similar issue.
First study their migration documentation.
https://developers.google.com/maps/documentation/places/android-sdk/client-migration

//Initialize this globally
PlacesClient placesClient;

//Inside your onCreate do the following
Places.initialize(getApplicationContext(), getString(R.string.Apikey)); placesClient = Places.createClient(this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants