I'm trying to display a MapView from ArcGis in Android Studio. I'm using Map Fragments for that, I put in the xml the Map and my other UI stuff. Putting the MapView element in the layout file always crashes, so I'm doing it this way (using android studio):
<SPAN class="pln" style="color: #000000;">my_main_activity</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">xml </SPAN><SPAN class="pun" style="color: #000000;"><</SPAN><SPAN class="pln" style="color: #000000;">android</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">support</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">v4</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">widget</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">DrawerLayout</SPAN><SPAN class="pln" style="color: #000000;"> xmlns</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">android</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://schemas.android.com/apk/res/android" target="_blank">http://schemas.android.com/apk/res/android</A><SPAN>"</SPAN></SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">id</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"@+id/maps_app_activity_drawer_layout"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_width</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"match_parent"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_height</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"match_parent"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;"><!--</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">The</SPAN><SPAN class="pln" style="color: #000000;"> main content view </SPAN><SPAN class="pun" style="color: #000000;">--></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;"><</SPAN><SPAN class="typ" style="color: #2b91af;">FrameLayout</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">id</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"@+id/maps_app_activity_content_frame"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_width</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"match_parent"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_height</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"match_parent"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">/></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;"><!--</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">The</SPAN><SPAN class="pln" style="color: #000000;"> navigation drawer </SPAN><SPAN class="pun" style="color: #000000;">--></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;"><</SPAN><SPAN class="typ" style="color: #2b91af;">ListView</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">id</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"@+id/maps_app_activity_left_drawer"</SPAN><SPAN class="pln" style="color: #000000;"> style</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"@style/drawer_listView_style"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_width</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"240dp"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_height</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"match_parent"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">layout_gravity</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"start"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">background</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"@android:color/darker_gray"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">choiceMode</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"singleChoice"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">divider</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"@color/esri_gray"</SPAN><SPAN class="pln" style="color: #000000;"> android</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;">dividerHeight</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="str" style="color: #800000;">"1px"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">/></SPAN>
and this is the framgent layout: map_fragment_layout.xml
<SPAN class="tag" style="color: #800000;"><FrameLayout</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">xmlns:android</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http://schemas.android.com/apk/res/android" target="_blank">http://schemas.android.com/apk/res/android</A><SPAN>"</SPAN></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">android:id</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;">"@+id/map_fragment_map_container_frame_layout"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">android:layout_width</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;">"match_parent"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">android:layout_height</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;">"match_parent"</SPAN><SPAN class="tag" style="color: #800000;">></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;"><!-- The map configuration --></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="tag" style="color: #800000;"><com.esri.android.map.MapView</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">android:id</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;">"@+id/map_layout"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">android:layout_width</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;">"fill_parent"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">android:layout_height</SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="atv" style="color: #0000ff;">"fill_parent"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atn" style="color: #ff0000;">initExtent</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="atv" style="color: #0000ff;">"-9934033.827 1537316.31 -9933312.043 1537940.728"</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="tag" style="color: #800000;">></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;"><!-- xmin ymin xmax ymax --></SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="tag" style="color: #800000;"></com.esri.android.map.MapView></SPAN>
My map fragment class holds every configuration of the MapView:
<SPAN class="lit" style="color: #800000;">@Override</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">public</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">View</SPAN><SPAN class="pln" style="color: #000000;"> onCreateView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">LayoutInflater</SPAN><SPAN class="pln" style="color: #000000;"> inflater</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pln" style="color: #000000;"> container</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="typ" style="color: #2b91af;">Bundle</SPAN><SPAN class="pln" style="color: #000000;"> savedInstanceState</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">{</SPAN><SPAN class="pln" style="color: #000000;"> mMapContainer </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">FrameLayout</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> inflater</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">inflate</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">R</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">layout</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">map_fragment_layout</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;">container</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="kwd" style="color: #00008b;">false</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// Add dynamic layer to MapView (Base)</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// Retrieve the map and initial extent from XML layout</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">MapView</SPAN><SPAN class="pln" style="color: #000000;"> mapView </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">MapView</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;">mMapContainer</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">findViewById</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">R</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">id</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">map_layout</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">ArcGISDynamicMapServiceLayer</SPAN><SPAN class="pln" style="color: #000000;"> baseMap </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">new</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">ArcGISDynamicMapServiceLayer</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">baseMapURL</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> mapView</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addLayer</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">baseMap</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">//Creates a dynamic layer using service URL</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">ArcGISDynamicMapServiceLayer</SPAN><SPAN class="pln" style="color: #000000;"> dynamicLayer </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">new</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">ArcGISDynamicMapServiceLayer</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">dynamicMapURL</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">//Adds layer into the 'MapView'</SPAN><SPAN class="pln" style="color: #000000;"> mapView</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addLayer</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">dynamicLayer</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// Set the MapView to allow the user to rotate the map when as part of a pinch gesture.</SPAN><SPAN class="pln" style="color: #000000;"> setMapView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">mapView</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> mapView</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">zoomin</SPAN><SPAN class="pun" style="color: #000000;">();</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">return</SPAN><SPAN class="pln" style="color: #000000;"> mMapContainer</SPAN><SPAN class="pun" style="color: #000000;">;</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">}</SPAN>the function setMapView configures the rest of MapView options:
<SPAN class="kwd" style="color: #00008b;">private</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">void</SPAN><SPAN class="pln" style="color: #000000;"> setMapView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="kwd" style="color: #00008b;">final</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">MapView</SPAN><SPAN class="pln" style="color: #000000;"> mapView</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">{</SPAN><SPAN class="pln" style="color: #000000;"> mMapView </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> mapView</SPAN><SPAN class="pun" style="color: #000000;">;</SPAN><SPAN class="pln" style="color: #000000;"> mMapView</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">setEsriLogoVisible</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="kwd" style="color: #00008b;">false</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> mMapView</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">enableWrapAround</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="kwd" style="color: #00008b;">true</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> mapView</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">setAllowRotationByPinch</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="kwd" style="color: #00008b;">true</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// Creating an inflater</SPAN><SPAN class="pln" style="color: #000000;"> mInflater </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">LayoutInflater</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> getActivity</SPAN><SPAN class="pun" style="color: #000000;">().</SPAN><SPAN class="pln" style="color: #000000;">getSystemService</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">Context</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">LAYOUT_INFLATER_SERVICE</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// Setting up the layout params for the searchview and searchresult layout</SPAN><SPAN class="pln" style="color: #000000;"> mlayoutParams </SPAN><SPAN class="pun" style="color: #000000;">=</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">new</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">FrameLayout</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">LayoutParams</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">LayoutParams</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">MATCH_PARENT</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="typ" style="color: #2b91af;">LayoutParams</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">WRAP_CONTENT</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">Gravity</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">LEFT </SPAN><SPAN class="pun" style="color: #000000;">|</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">Gravity</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">TOP</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> mlayoutParams</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">setMargins</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">LEFT_MARGIN_SEARCH</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> TOP_MARGIN_SEARCH</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;">RIGHT_MARGIN_SEARCH</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> BOTTOM_MARGIN_SEARCH</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// set MapView into the activity layout</SPAN><SPAN class="pln" style="color: #000000;"> mMapContainer</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">mMapView</SPAN><SPAN class="pun" style="color: #000000;">);</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="com" style="color: #808080;">// Displaying the searchbox layout</SPAN><SPAN class="pln" style="color: #000000;"> showSearchBoxLayout</SPAN><SPAN class="pun" style="color: #000000;">();</SPAN>After debuging this error shows up:
<SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">lang</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">RuntimeException</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">Unable</SPAN><SPAN class="pln" style="color: #000000;"> to start activity </SPAN><SPAN class="typ" style="color: #2b91af;">ComponentInfo</SPAN><SPAN class="pun" style="color: #000000;">{</SPAN><SPAN class="pln" style="color: #000000;">zero</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">ucamaps</SPAN><SPAN class="pun" style="color: #000000;">/</SPAN><SPAN class="pln" style="color: #000000;">zero</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">ucamaps</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">MainActivity</SPAN><SPAN class="pun" style="color: #000000;">}:</SPAN><SPAN class="pln" style="color: #000000;"> java</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">lang</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">IllegalStateException</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">The</SPAN><SPAN class="pln" style="color: #000000;"> specified child already has a parent</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="typ" style="color: #2b91af;">You</SPAN><SPAN class="pln" style="color: #000000;"> must call removeView</SPAN><SPAN class="pun" style="color: #000000;">()</SPAN><SPAN class="pln" style="color: #000000;"> on the child</SPAN><SPAN class="str" style="color: #800000;">'s parent first. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child'</SPAN><SPAN class="pln" style="color: #000000;">s parent first</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;"> at android</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">view</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addViewInner</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">3936</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> at android</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">view</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">3786</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> at android</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">view</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">3727</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> at android</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">view</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">addView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">ViewGroup</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">3700</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> at zero</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">ucamaps</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">MapFragment</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">setMapView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">MapFragment</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">313</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> at zero</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">ucamaps</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">MapFragment</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">onCreateView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">MapFragment</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">209</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN><SPAN class="pln" style="color: #000000;"> at android</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">app</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="typ" style="color: #2b91af;">Fragment</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">performCreateView</SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="typ" style="color: #2b91af;">Fragment</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">java</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="lit" style="color: #800000;">2053</SPAN><SPAN class="pun" style="color: #000000;">)</SPAN>I've tried removing the the MapView from it's parent before returning from getMapView(), and that still crashes. Any help at all would be appreciated.
arcgis android