I'm doing an accessibility project and need to use the API Map. I can not see the map in Android Studio. This error appears:
Unknown Fragments - The <fragment> tag allows the layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout.
- <fragment com.google.android.gms.maps.SupportMapFragment ...> (Pick Layout ...)
Do not warn about <fragment> tags in this session.
Does anyone have a solution?

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity" />
The issue here is that the Android studio IDE does not know which fragment to insert in the layout editor because the fragment is inserted at run time.
To resolve, follow these steps (the steps below are for a Sceneform fragment example but same principle applies for other fragments)



Choose the one that you are using and click on it.
Android studio will add a line to your layout to tell the editor to use this layout in the preview.
The line added will look something like:
<fragment
android:id="@+id/ux_fragment"
android:name="com.google.ar.sceneform.ux.ArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/sceneform_ux_fragment_layout" /> //This the new line inserted
Short answer:
Just add this line to fragment tag:
tools:layout="@layout/your_fragment_layout"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With