Note that there are some explanatory texts on larger screens.

plurals
  1. POError trying to add a map: android.view.InflateException: Binary XML file line #9: Error inflating class com.google.android.maps.MapView
    primarykey
    data
    text
    <p>I create the following class who extends MapActivity. The error is in this class here in the line </p> <p>View view = infalInflater.inflate(R.layout.car_map_view, null);</p> <pre><code>public class ShowCarMapChild extends MapActivity { private MapView mapView; private Car car; private String tag; @Override protected void onCreate(Bundle icicle) { // TODO Auto-generated method stub super.onCreate(icicle); setContentView(R.layout.car_map_view); } public void setCar(Car car){ this.car = car; } public void setTag (String tag){ this.tag = tag; } public String getTag (){ return tag; } public View getMapView(Context context){ LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE); View view = infalInflater.inflate(R.layout.car_map_view, null); setMap(view,context); return view; } public void setMap(View view, Context context){ mapView = (MapView) view.findViewById(R.id.mapShowCarLocation); MapController mc = mapView.getController(); mc.animateTo(car.getLocation()); mc.setZoom(15); PinpointItem point = new PinpointItem(car.getLocation(), car, context); Drawable d = getResources().getDrawable(R.drawable.pinpoint); CustomPinpointOverlay overlay = new CustomPinpointOverlay(d); overlay.insertPinpoint(point); mapView.getOverlays().add(overlay); } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } </code></pre> <p>}</p> <p>This is the xml file:</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="150dip" android:orientation="vertical" &gt; &lt;com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mapShowCarLocation" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apiKey="0UFOPeLgKxoW8VGjdzV5QN6N53N7733i1kTFI3g" android:enabled="true" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And this is the Adapter </p> <p>public class ShowCarExpandListAdapter extends BaseExpandableListAdapter {</p> <pre><code>private Context context; private ArrayList&lt;ShowCarExpandGroup&gt; groups; private Car car; public ShowCarExpandListAdapter (Context context, ArrayList&lt;ShowCarExpandGroup&gt; groups, Car car){ this.context = context; this.groups = groups; this.car = car; } public void addItem(ShowCarExpandChild item, ShowCarExpandGroup group){ if (!groups.contains(group)){ groups.add(group); } int index = groups.indexOf(group); ArrayList&lt;ShowCarExpandChild&gt; ch = groups.get(index).getItems(); ch.add(item); groups.get(index).setItems(ch); } public void addItem(ShowCarMapChild item, ShowCarExpandGroup group){ if (!groups.contains(group)){ groups.add(group); } int index = groups.indexOf(group); ArrayList&lt;ShowCarMapChild&gt; ch = groups.get(index).getMapItems(); ch.add(item); groups.get(index).setMapItems(ch); } public Object getChild(int groupPosition, int childPosition) { // TODO Auto-generated method stub if (groupPosition == 0){ ArrayList&lt;ShowCarMapChild&gt; chList = groups.get(groupPosition).getMapItems(); return chList.get(childPosition); }else{ ArrayList&lt;ShowCarExpandChild&gt; chList = groups.get(groupPosition).getItems(); return chList.get(childPosition); } } public long getChildId(int groupPosition, int childPosition) { // TODO Auto-generated method stub return childPosition; } public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view, ViewGroup parent) { // TODO Auto-generated method stub if (view == null){ if (groupPosition == 0){ ShowCarMapChild mapChild = (ShowCarMapChild) getChild(groupPosition, childPosition); view = mapChild.getMapView(context); //LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE); //ShowCarMapChild mapChild = (ShowCarMapChild) getChild(groupPosition, childPosition); //view = infalInflater.inflate(R.layout.car_map_view, null); //MapView mv = mapChild.getMap(view, context); //mv.setTag(mapChild.getTag()); }else{ LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE); ShowCarExpandChild child = (ShowCarExpandChild) getChild(groupPosition, childPosition); view = infalInflater.inflate(R.layout.car_child, null); TextView tv = (TextView) view.findViewById(R.id.tvChild); tv.setText(child.getName()); tv.setTag(child.getTag()); } } return view; } public int getChildrenCount(int groupPosition) { // TODO Auto-generated method stub if (groupPosition == 0){ ArrayList&lt;ShowCarMapChild&gt; chList = groups.get(groupPosition).getMapItems(); return chList.size(); }else{ ArrayList&lt;ShowCarExpandChild&gt; chList = groups.get(groupPosition).getItems(); return chList.size(); } } public Object getGroup(int groupPosition) { // TODO Auto-generated method stub return groups.get(groupPosition); } public int getGroupCount() { // TODO Auto-generated method stub return groups.size(); } public long getGroupId(int groupPosition) { // TODO Auto-generated method stub return groupPosition; } public View getGroupView(int groupPosition, boolean isLastChild, View view, ViewGroup parent) { // TODO Auto-generated method stub ShowCarExpandGroup group = (ShowCarExpandGroup) getGroup(groupPosition); if(view == null){ LayoutInflater inf = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE); view = inf.inflate(R.layout.car_group, null); } TextView tv = (TextView) view.findViewById(R.id.tvGroup); tv.setText(group.getName()); return view; } public boolean hasStableIds() { // TODO Auto-generated method stub return true; } public boolean isChildSelectable(int arg0, int arg1) { // TODO Auto-generated method stub return true; } </code></pre> <p>}</p> <p>Here goes the main activity:</p> <pre><code> public class ShowCarExpList extends Activity { private static final int CODE_CHANGE_DETAILS = 1; private ShowCarExpandListAdapter expAdapter; private ArrayList&lt;ShowCarExpandGroup&gt; expListItems; private ExpandableListView expandList; private Button back; private Button edit; private Button book; private TextView brand; private ImageView image; private Car car; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d("hemendik pasetan da", "egixe da?"); setContentView(R.layout.car); setUpViews(); expandList = (ExpandableListView) findViewById (R.id.expCarList); expListItems = setStandardGroups(); expAdapter = new ShowCarExpandListAdapter (ShowCarExpList.this, expListItems, car); expandList.setAdapter(expAdapter); // Set up our adapter } private void setUpViews() { // TODO Auto-generated method stub back = (Button)findViewById (R.id.btnBackCarView); edit = (Button)findViewById (R.id.btnEditCarView); book = (Button)findViewById (R.id.btnBookCarCarView); Intent i = getIntent(); car = (Car) i.getParcelableExtra("car"); brand = (TextView)findViewById (R.id.txtCarViewBrand); image = (ImageView)findViewById (R.id.ivCarMainPhoto); String urlString = "http://tapazz.com/autopia/upload/cars/"+car.getPhotoUrl(); DrawableManager.fetchDrawableOnThread(urlString, image, null); brand.setText(car.getBrand()+" "+car.getModel()); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent in = new Intent(ShowCarExpList.this, MyCarsFragment.class); ShowCarExpList.this.startActivity(in); } }); edit.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(ShowCarExpList.this, AddCarActivity.class); intent.putExtra("car", car); startActivityForResult(intent, CODE_CHANGE_DETAILS); } }); } public ArrayList&lt;ShowCarExpandGroup&gt; setStandardGroups(){ ArrayList&lt;ShowCarExpandGroup&gt; list = new ArrayList&lt;ShowCarExpandGroup&gt;(); ArrayList&lt;ShowCarExpandChild&gt; list2; ArrayList&lt;ShowCarMapChild&gt; listMap = new ArrayList&lt;ShowCarMapChild&gt;(); ShowCarExpandGroup gru1 = new ShowCarExpandGroup(); gru1.setName(" Location"); ShowCarMapChild ch1_1 = new ShowCarMapChild(); ch1_1.setCar(car); ch1_1.setTag(null); listMap.add(ch1_1); gru1.setMapItems(listMap); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru2 = new ShowCarExpandGroup(); gru2.setName(" License Plate"); ShowCarExpandChild ch2_1 = new ShowCarExpandChild(); ch2_1.setName(car.getLicensePlate()); ch2_1.setTag(null); list2.add(ch2_1); gru2.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru3 = new ShowCarExpandGroup(); gru3.setName(" Description"); ShowCarExpandChild ch3_1 = new ShowCarExpandChild(); if (car.getDescription()==null){ ch3_1.setName("Sorry no description available"); }else{ ch3_1.setName(car.getDescription()); } ch3_1.setTag(null); list2.add(ch3_1); gru3.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru4 = new ShowCarExpandGroup(); gru4.setName(" Pricing"); ShowCarExpandChild ch4_1 = new ShowCarExpandChild(); ch4_1.setName("Price per hour: "+((Double)car.getPricePerHour()).toString()); ch4_1.setTag(null); list2.add(ch4_1); ShowCarExpandChild ch4_2 = new ShowCarExpandChild(); ch4_2.setName("Price per km: "+((Double)car.getPricePerKm()).toString()); ch4_2.setTag(null); list2.add(ch4_2); gru4.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru5 = new ShowCarExpandGroup(); gru5.setName(" Host/Owner"); ShowCarExpandChild ch5_1 = new ShowCarExpandChild(); ch5_1.setName("Maarten"); ch5_1.setTag(null); list2.add(ch5_1); gru5.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru6 = new ShowCarExpandGroup(); gru6.setName(" Reviews"); setReviews(); ShowCarExpandChild ch6_1 = new ShowCarExpandChild(); ch6_1.setName("no reviews"); ch6_1.setTag(null); list2.add(ch6_1); gru6.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru7 = new ShowCarExpandGroup(); gru7.setName(" Insurance"); ShowCarExpandChild ch7_1 = new ShowCarExpandChild(); ch7_1.setName(car.getInsuranceCompany()); ch7_1.setTag(null); list2.add(ch7_1); gru7.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru8 = new ShowCarExpandGroup(); gru8.setName(" More Pictures"); ShowCarExpandChild ch8_1 = new ShowCarExpandChild(); ch8_1.setName("no pictures"); ch8_1.setTag(null); list2.add(ch8_1); gru8.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru9 = new ShowCarExpandGroup(); gru9.setName(" Availability"); ShowCarExpandChild ch9_1 = new ShowCarExpandChild(); ch9_1.setName("now available"); ch9_1.setTag(null); list2.add(ch9_1); gru9.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru10 = new ShowCarExpandGroup(); gru10.setName(" Sharing settings"); ShowCarExpandChild ch10_1 = new ShowCarExpandChild(); ch10_1.setName("private"); ch10_1.setTag(null); list2.add(ch10_1); gru10.setItems(list2); list2 = new ArrayList&lt;ShowCarExpandChild&gt;(); ShowCarExpandGroup gru11 = new ShowCarExpandGroup(); gru11.setName(" Keyless lock"); ShowCarExpandChild ch11_1 = new ShowCarExpandChild(); ch11_1.setName("Keylock installed! :)"); ch11_1.setTag(null); list2.add(ch11_1); gru11.setItems(list2); list.add(gru1); list.add(gru2); list.add(gru3); list.add(gru4); list.add(gru5); list.add(gru6); list.add(gru7); list.add(gru8); list.add(gru9); list.add(gru10); list.add(gru11); return list; } private void setReviews() { // TODO Auto-generated method stub } </code></pre> <p>}</p> <p>and the error that it gives:</p> <pre><code> 10-24 16:09:48.218: E/AndroidRuntime(353): FATAL EXCEPTION: main 10-24 16:09:48.218: E/AndroidRuntime(353): android.view.InflateException: Binary XML file line #7: Error inflating class com.google.android.maps.MapView 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.createView(LayoutInflater.java:513) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.inflate(LayoutInflater.java:407) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 10-24 16:09:48.218: E/AndroidRuntime(353): at com.tapazz.car.ShowCarMapChild.getMapView(ShowCarMapChild.java:44) 10-24 16:09:48.218: E/AndroidRuntime(353): at com.tapazz.car.ShowCarExpandListAdapter.getChildView(ShowCarExpandListAdapter.java:80) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:450) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.AbsListView.obtainView(AbsListView.java:1315) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.ListView.makeAndAddView(ListView.java:1727) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.ListView.fillDown(ListView.java:652) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.ListView.fillSpecific(ListView.java:1284) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.ListView.layoutChildren(ListView.java:1558) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.AbsListView.onLayout(AbsListView.java:1147) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.View.layout(View.java:7035) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.View.layout(View.java:7035) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.View.layout(View.java:7035) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.ScrollView.onLayout(ScrollView.java:1205) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.View.layout(View.java:7035) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.View.layout(View.java:7035) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.View.layout(View.java:7035) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.os.Handler.dispatchMessage(Handler.java:99) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.os.Looper.loop(Looper.java:123) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.app.ActivityThread.main(ActivityThread.java:4627) 10-24 16:09:48.218: E/AndroidRuntime(353): at java.lang.reflect.Method.invokeNative(Native Method) 10-24 16:09:48.218: E/AndroidRuntime(353): at java.lang.reflect.Method.invoke(Method.java:521) 10-24 16:09:48.218: E/AndroidRuntime(353): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 10-24 16:09:48.218: E/AndroidRuntime(353): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 10-24 16:09:48.218: E/AndroidRuntime(353): at dalvik.system.NativeStart.main(Native Method) 10-24 16:09:48.218: E/AndroidRuntime(353): Caused by: java.lang.reflect.InvocationTargetException 10-24 16:09:48.218: E/AndroidRuntime(353): at com.google.android.maps.MapView.&lt;init&gt;(MapView.java:238) 10-24 16:09:48.218: E/AndroidRuntime(353): at java.lang.reflect.Constructor.constructNative(Native Method) 10-24 16:09:48.218: E/AndroidRuntime(353): at java.lang.reflect.Constructor.newInstance(Constructor.java:446) 10-24 16:09:48.218: E/AndroidRuntime(353): at android.view.LayoutInflater.createView(LayoutInflater.java:500) 10-24 16:09:48.218: E/AndroidRuntime(353): ... 38 more 10-24 16:09:48.218: E/AndroidRuntime(353): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity. 10-24 16:09:48.218: E/AndroidRuntime(353): at com.google.android.maps.MapView.&lt;init&gt;(MapView.java:282) 10-24 16:09:48.218: E/AndroidRuntime(353): at com.google.android.maps.MapView.&lt;init&gt;(MapView.java:255) 10-24 16:09:48.218: E/AndroidRuntime(353): ... 42 more </code></pre> <p>Hope it will be helpfull</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload