Updating Android Studio breaks Google Maps -
updating android studio 2.2.1 2.2.2 has broken project, since unable access related google maps. project worked fine before update, nothing works now. making entirely new project based in google maps activity doesn't work either , gives me exact same crash report , results.
what have tried: - updating of sdk's, google related ones. - generated new google api key - creating entirely new project scratch - changed supportmapfragment mapfragment
error getting when try run project , entirely new maps project on phone (same error(all other gmaps apps work on phone, don't think that's issue)):
caused by: android.view.inflateexception: binary xml file line #1: binary xml file line #1: error inflating class fragment
my build.gradle(new project scratch):
apply plugin: 'com.android.application' android { compilesdkversion 24 buildtoolsversion "24.0.2" defaultconfig { applicationid "com.example.simon.afinal" minsdkversion 19 targetsdkversion 24 versioncode 1 versionname "1.0" testinstrumentationrunner "android.support.test.runner.androidjunitrunner" } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) androidtestcompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:24.2.1' compile 'com.google.android.gms:play-services:9.8.0' testcompile 'junit:junit:4.12' }
standard maps activity:
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 supportmapfragment , notified when map ready used. supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.map); mapfragment.getmapasync(this); } @override public void onmapready(googlemap googlemap) { mmap = googlemap; // add marker in sydney , move camera latlng sydney = new latlng(-34, 151); mmap.addmarker(new markeroptions().position(sydney).title("marker in sydney")); mmap.movecamera(cameraupdatefactory.newlatlng(sydney)); } }
gmaps xml layout file:
<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" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.simon.afinal.mapsactivity" tools:layout="@layout/activity_maps" />
all appreciated!
use google map
if (googlemap == null) { googlemap = ((supportmapfragment) getchildfragmentmanager() .findfragmentbyid(r.id.map)).getmap();
in xml map in frame layout
<fragment android:id="@+id/map" class="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="match_parent" />
onmapready method this
@override public void onmapready(googlemap googlemap) { this.googlemap = googlemap; }
Comments
Post a Comment