Android Studio: xmlns: map does not work

After much research and not finding anything ... quick question, does anyone have an idea why Android Studio doesn't take the Map tag? The code below is a snippet of sample cards in the SDK. Google game services and support have already been added, but nothing.

It shows an error

Unexpected namespace prefix "map" found for tag fragment. 

Thank you very much!

 <fragment xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" map:cameraZoom="10" /> 
+6
source share
3 answers

I had the same problem as soon as I moved the map fragment to FrameLayout (so that I could add a button on top of the map).

I don't know what I really did, since I am noob in Android apps and XML, but it looks like I found a solution :-)

I tried to do the trick, including the fragment, from a separate file (using the 'include' directive), and as soon as I put the exposed fragment of the map without any namespace definitions, he offered me 2 options: XMLNS: map = "http: / /schemas.android.com/apk/res-auto "XMLNS: map =" http://schemas.android.com/tools "I realized that maybe the second one will work in the original file (although in the original Android Studio file does not offer it, but only the 1st).

Conclusion: Just change this line: XMLNS: map = "http://schemas.android.com/apk/res-auto" with this: XMLNS: map = "http://schemas.android.com/tools"

HOW I APPLIED - I AM MY AND CAN MAY DECIDE THAT SOME SIDE SIDE EFFECTS, PLEASE, LET THAT YOU CAN KNOW IF IF THIS (although everything seemed to work fine so far ...).

What is my working map layout with a button on top and without errors:

 <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:map="http://schemas.android.com/tools" tools:context="com.maverickrider.myapp.inviteActivity.MapsActivity" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/purpura_E51B4A"> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/map" android:name="com.google.android.gms.maps.MapFragment" map:cameraTargetLat="51.513259" map:cameraTargetLng="-0.129147" map:cameraTilt="30" map:cameraZoom="13" /> <Button android:id="@+id/startActivityButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal|center_vertical" android:onClick="cokolwiek" android:text="Baton z dupy" android:layout_alignParentBottom="true" /> </FrameLayout > 
+2
source

I also had this problem. I did Project / Clean and the error went away and now it works fine. This assumes that the map namespace is correctly defined above where it is used.

0
source

I run 0.5.8, and the XML viewer emphasizes attrs with a map: - however, the application works fine. YMMMV.

0
source

Source: https://habr.com/ru/post/946812/


All Articles