Search code examples
javaandroidgoogle-mapsgoogle-places-apigoogle-places-autocomplete

Does not recognize AutocompleteSupportFragment from places library


Designer tells me unknown fragment, but it seems like im importing the library correctly as import com.google.android.libraries.places.widget.AutocompleteSupportFragment; does not generate error and the palces api seems to be correctly refenenced as well. Does anyone know why it might be? i thought that maybe the library no longer holds it, but official sources still have it ...

Part of the xml layout that generates error

<fragment
        android:id="@+id/autocomplete_fragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
  android:name="com.google.android.libraries.places.widget.AutocompleteSupportFragment"/> ```


inicializing it in the java class

AutocompleteSupportFragment autocompleteFragment = (AutocompleteSupportFragment)   
           getSupportFragmentManager().findFragmentById(R.id.autocomplete_fragment);

Ive looked for information in developer android and maps platform but everything seems to be the same. I have not yet written the functionality of the fragment as it does not recognize it on the first place. I dont know if that has any influence on it.


Solution

  • Clear caches and start Android Studio again, to invalidate and restart, select File > Invalidate Caches / Restart... This will restart Android Studio and clean the caches, which can assist in resolving difficulties with the designer preview.