google maps - Android SupportMapFragment did not create a view error -
im struggling figure out weird issue. in android app have fragment contains support map fragment. google maps works fine when gps turned on , fragment creates fine. when gps turned off app wont instantiate, crashes upon opening it.
here stack trace:
07-31 22:35:47.905: e/androidruntime(32324): fatal exception: main 07-31 22:35:47.905: e/androidruntime(32324): android.view.inflateexception: binary xml file line #9: error inflating class fragment 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.rinflate(layoutinflater.java:746) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.inflate(layoutinflater.java:489) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.inflate(layoutinflater.java:396) 07-31 22:35:47.905: e/androidruntime(32324): @ au.net.gokart.fragments.trackinfofragment.oncreateview(trackinfofragment.java:69) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragment.performcreateview(fragment.java:1478) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:927) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1104) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1460) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:472) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragmentpageradapter.finishupdate(fragmentpageradapter.java:141) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.view.viewpager.populate(viewpager.java:1068) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.view.viewpager.populate(viewpager.java:914) 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.view.viewpager.onmeasure(viewpager.java:1436) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.view.measure(view.java:15524) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5109) 07-31 22:35:47.905: e/androidruntime(32324): @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.view.measure(view.java:15524) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5109) 07-31 22:35:47.905: e/androidruntime(32324): @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.view.measure(view.java:15524) 07-31 22:35:47.905: e/androidruntime(32324): @ android.widget.linearlayout.measurevertical(linearlayout.java:833) 07-31 22:35:47.905: e/androidruntime(32324): @ android.widget.linearlayout.onmeasure(linearlayout.java:574) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.view.measure(view.java:15524) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5109) 07-31 22:35:47.905: e/androidruntime(32324): @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-31 22:35:47.905: e/androidruntime(32324): @ com.android.internal.policy.impl.phonewindow$decorview.onmeasure(phonewindow.java:2397) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.view.measure(view.java:15524) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:1986) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1227) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1400) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1120) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4604) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.choreographer$callbackrecord.run(choreographer.java:725) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.choreographer.docallbacks(choreographer.java:555) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.choreographer.doframe(choreographer.java:525) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) 07-31 22:35:47.905: e/androidruntime(32324): @ android.os.handler.handlecallback(handler.java:615) 07-31 22:35:47.905: e/androidruntime(32324): @ android.os.handler.dispatchmessage(handler.java:92) 07-31 22:35:47.905: e/androidruntime(32324): @ android.os.looper.loop(looper.java:137) 07-31 22:35:47.905: e/androidruntime(32324): @ android.app.activitythread.main(activitythread.java:4921) 07-31 22:35:47.905: e/androidruntime(32324): @ java.lang.reflect.method.invokenative(native method) 07-31 22:35:47.905: e/androidruntime(32324): @ java.lang.reflect.method.invoke(method.java:511) 07-31 22:35:47.905: e/androidruntime(32324): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1038) 07-31 22:35:47.905: e/androidruntime(32324): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:805) 07-31 22:35:47.905: e/androidruntime(32324): @ dalvik.system.nativestart.main(native method) 07-31 22:35:47.905: e/androidruntime(32324): caused by: java.lang.illegalstateexception: fragment com.google.android.gms.maps.supportmapfragment did not create view. 07-31 22:35:47.905: e/androidruntime(32324): @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:308) 07-31 22:35:47.905: e/androidruntime(32324): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:676) 07-31 22:35:47.905: e/androidruntime(32324): ... 46 more
this layout xml:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <fragment android:id="@+id/map2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginleft="10dp" android:layout_marginright="10dp" class="com.google.android.gms.maps.supportmapfragment" map:uirotategestures="true" map:uiscrollgestures="true" map:uitiltgestures="true" map:uizoomcontrols="true" map:uizoomgestures="true" /> </linearlayout>
this fragment oncreateview
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { super.oncreateview(inflater, container, savedinstancestate); this.activity = this.getactivity(); actionbar ab = getactivity().getactionbar(); if (ab.getnavigationmode() == actionbar.navigation_mode_standard) { ab.setnavigationmode(actionbar.navigation_mode_tabs); } ab.setdisplayhomeasupenabled(false); checkforgoogleplayservices(); view view = inflater.inflate(r.layout.fragment_trackinfo, container, false); setupmapifneeded(); return view; }
any appreciated
i managed solve this answer.
you need change fragment
keyword in layout xml framelayout
.
Comments
Post a Comment