If you want to use a view instead of a map fragment, then this is the implementation I applied to get this transition from a project that used the previous version of game services. Updated to 9.6.0 to match the new FCM and caused problems in our map fragments.
private MapView mapView; private GoogleMap mMap; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // inflate and return the layout // inflate and return the layout View v = inflater.inflate(R.layout.mapFragment, container, false); mapView = (MapView) v.findViewById(R.id.map); mapView.onCreate(savedInstanceState); mapView.onResume(); mapView.getMapAsync(this); return v; } @Override public void onMapReady(GoogleMap map) { mMap = map; }
And in your fragment:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/Sismos" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#FFFFFF" android:orientation="vertical" > <com.google.android.gms.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout>
It is important to note the following permissions for your manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" />
I managed to achieve this setup without any errors in API 23 and the following libs on my Gradle:
compile 'com.google.android.gms:play-services:9.6.0' compile 'com.google.android.gms:play-services-maps:9.6.0'
Hope this helps!
source share