Error of Inflateexception

Asked

Viewed 83 times

1

I’m getting an error of InflateException, but I don’t know how to solve.

Error:

Caused by: android.view.Inflateexception: Binary XML file line #1: Binary XML file line #1: Error inflating class Fragment at android.view.Layoutinflater.inflate(Layoutinflater.java:539) at android.view.Layoutinflater.inflate(Layoutinflater.java:423) at br.com.projeto.caminhossembarreiras.Mainfragment.onCreateView(Mainfragment.java:23)

Error line:

 View rootView = inflater.inflate(R.layout.fragment_main, container, false);

Class:

public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);

        MapFragment fragment = (MapFragment)getChildFragmentManager().findFragmentById(R.id.map);
        fragment.getMapAsync(this);

        return rootView;
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {

        LatLng marker = new LatLng(-33.867, 151.206);

        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(marker, 13));

        googleMap.addMarker(new MarkerOptions().title("Hello Google Maps!").position(marker));

XML:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context="br.com.projeto.caminhossembarreiras.MainActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
  • What are the other xml of the project? Check if there are any errors in any of them.

  • There is no error in any xml.

  • This is usually XML error itself.

  • @Larisouza you are managing to import the R class?

  • I am @Caiqueoliveira.

  • 1

    That’s all xml what do you have? I don’t think it should be the one you should use in inflate.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.