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.
– Caique Oliveira
There is no error in any xml.
– Lari Souza
This is usually XML error itself.
– Pablo Almeida
@Larisouza you are managing to import the R class?
– Caique Oliveira
I am @Caiqueoliveira.
– Lari Souza
That’s all xml what do you have? I don’t think it should be the one you should use in inflate.
– ramaral