0
When I run my app, after selecting the event that directs to a activity
using maps, it ends with Fatal Exception
.
luizugliano.com.br.lugaresfavoritos.Mapsactivity}: android.view.Inflateexception: Binary XML file line #12: Binary XML file line #12: Error inflating class Fragment
I’m using the API23
and performed the update for support SupportMapFragment
.
activity_maps
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
também tentei com: android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="luizugliano.com.br.lugaresfavoritos.MapsActivity" />
</LinearLayout>
build.Gradle dependencies
compile 'com.google.android.gms:play-services:6.+'
Mapsactivity (I just created a new map app by Android Studio itself)
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Intent intent = getIntent();
Log.i("InfoLocalizacao", Integer.toString(intent.getIntExtra("InfoLocalizacao", -1)));
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
The layout that has the map is the one that posted or beyond the Fragment has more views?
– ramaral
@ramaral the app has two layouts but only the one I posted has the map.
– Luiz Henrique Ugliano
Change the gsm Compile from:
compile 'com.google.android.gms:play-services:6.+'
for:compile 'com.google.android.gms:play-services:8.1.0'
. And add your manifest file.– Luiz