I was using the old Place SDK which was working fine But it is going to be depreciated and I move to new place SDK. I got keep the crashing report from a few devices.
Crashes Report:
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'
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.
}
});
Layout XML
<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" />