android - Binary XML file line #1: Error inflating class fragment when running map -
i have problemes when executing simple map in android studio,
here map activity :
package com.dev.boblinux.cador.activities; import android.manifest; import android.content.pm.packagemanager; import android.os.bundle; import android.support.v4.app.activitycompat; import android.support.v4.app.fragmentactivity; import com.dev.boblinux.cador.r; 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; public class chomemapctrl extends fragmentactivity implements onmapreadycallback { private googlemap mmap; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_chome_map_ctrl); // obtain supportmapfragment , notified when map ready used. supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.map); mapfragment.getmapasync(this); } /** * manipulates map once available. * callback triggered when map ready used. * can add markers or lines, add listeners or move camera. in case, * add marker near sydney, australia. * if google play services not installed on device, user prompted install * inside supportmapfragment. method triggered once user has * installed google play services , returned app. */ @override public void onmapready(googlemap googlemap) { mmap = googlemap; mmap.settrafficenabled(true); if (activitycompat.checkselfpermission(this, manifest.permission.access_fine_location) != packagemanager.permission_granted && activitycompat.checkselfpermission(this, manifest.permission.access_coarse_location) != packagemanager.permission_granted) { // todo: consider calling // activitycompat#requestpermissions // here request missing permissions, , overriding // public void onrequestpermissionsresult(int requestcode, string[] permissions, // int[] grantresults) // handle case user grants permission. see documentation // activitycompat#requestpermissions more details. return; } mmap.setmylocationenabled(true); mmap.getuisettings().setcompassenabled(true); mmap.getuisettings().setmaptoolbarenabled(false); //mmap.setmaptype(googlemap.map_type_hybrid); mmap.setmaptype(googlemap.map_type_terrain); mmap.movecamera(cameraupdatefactory.newlatlng(new latlng(48.856614, 2.3522219000000177))); } }
here androidmanifest `
<!-- access_coarse/fine_location permissions not required use google maps android api v2, must specify either coarse or fine location permissions 'mylocation' functionality. --> <!-- permission required run webview --> <uses-permission android:name="android.permission.access_fine_location" /> <!-- permission required send sms --> <uses-permission android:name="android.permission.send_sms" /> <!-- permission required receive sms --> <uses-permission android:name="android.permission.receive_sms" /> <!-- permission required read sms --> <uses-permission android:name="android.permission.read_sms" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name="com.dev.boblinux.cador.activities.mainactivity"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <!-- api key google maps-based apis defined string resource. (see file "res/values/google_maps_api.xml"). note api key linked encryption key used sign apk. need different api key each encryption key, including release key used sign apk publishing. can define keys debug , release targets in src/debug/ , src/release/. --> <meta-data android:name="com.google.android.geo.api_key" android:value="@string/google_maps_key" /> <activity android:name="com.dev.boblinux.cador.activities.chomemapctrl" android:label="@string/title_activity_chome_map_ctrl" /> <!-- line let sms receiver running in background--> <receiver android:name="com.dev.boblinux.cador.activities.smsreceiver"> <intent-filter> <action android:name="android.provider.telephony.sms_received" /> </intent-filter> </receiver> </application>
and here map ressource :
<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=".activities.chomemapctrl" />
last not least, error code :
02-07 21:36:59.773 2497-2497/com.dev.boblinux.cador e/androidruntime: fatal exception: main process: com.dev.boblinux.cador, pid: 2497 java.lang.runtimeexception: unable start activity componentinfo{com.dev.boblinux.cador/com.dev.boblinux.cador.activities.chomemapctrl}: android.view.inflateexception: binary xml file line #1: binary xml file line #1: error inflating class fragment @ android.app.activitythread.performlaunchactivity(activitythread.java:2416) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.-wrap11(activitythread.java) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: android.view.inflateexception: binary xml file line #1: binary xml file line #1: error inflating class fragment @ android.view.layoutinflater.inflate(layoutinflater.java:539) @ android.view.layoutinflater.inflate(layoutinflater.java:423) @ android.view.layoutinflater.inflate(layoutinflater.java:374) @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393) @ android.app.activity.setcontentview(activity.java:2166) @ com.dev.boblinux.cador.activities.chomemapctrl.oncreate(chomemapctrl.java:23) @ android.app.activity.performcreate(activity.java:6237) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1107) @ android.app.activitythread.performlaunchactivity(activitythread.java:2369) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.-wrap11(activitythread.java) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: android.view.inflateexception: binary xml file line #1: error inflating class fragment @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:782) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) @ android.view.layoutinflater.inflate(layoutinflater.java:492) @ android.view.layoutinflater.inflate(layoutinflater.java:423) @ android.view.layoutinflater.inflate(layoutinflater.java:374) @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393) @ android.app.activity.setcontentview(activity.java:2166) @ com.dev.boblinux.cador.activities.chomemapctrl.oncreate(chomemapctrl.java:23) @ android.app.activity.performcreate(activity.java:6237) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1107) @ android.app.activitythread.performlaunchactivity(activitythread.java:2369) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476) @ android.app.activitythread.-wrap11(activitythread.java) @ android.app.activitythread$h.handlemessage(activitythread.java:1344) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) caused by: java.lang.nullpointerexception: attempt invoke virtual method 'boolean java.io.file.mkdir()' on null object reference @ com.google.maps.api.android.lib6.gmm6.m.ad.a(unknown source) @ com.google.maps.api.android.lib6.gmm6.c.h.a(unknown source) @ com.google.maps.api.android.lib6.gmm6.c.ao.a(unknown source) @ com.google.maps.api.android.lib6.e.bd.a(unknown source) @ com.google.maps.api.android.lib6.e.ev.a(unknown source) @ com.google.maps.api.android.lib6.e.z.a(unknown source) @ com.google.maps.api.android.lib6.e.y.a(unknown source) @ com.google.android.gms.maps.internal.u.ontransact(sourcefile:107) @ android.os.binder.transact(binder.java:387) @ com.google.android.gms.maps.internal.imapfragmentdelegate$zza$zza.oncreateview(unknown source) @ com.google.android.gms.maps.supportmapfragment$zza.oncreateview(unknown source) @ com.google.android.gms.dynamic.zza$4.zzb(unknown source) @ com.google.android.gms.dynamic.zza.zza(unknown source) @ com.google.android.gms.dynamic.zza.oncreateview(unknown source) @ com.google.android.gms.maps.supportmapfragment.oncreateview(unknown source) @ android.support.v4.app.fragment.performcreateview(fragment.java:1962) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1036) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1226) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1328) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2284) @ android.support.v4.app.fragmentcontroller.oncreateview(fragmentcontroller.java:111) @ android.support.v4.app.fragmentactivity.dispatchfragmentsoncreateview(fragmentactivity.java:314) @ android.support.v4.app.basefragmentactivityhoneycomb.oncreateview(basefragmentactivityhoneycomb.java:31) @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:79) @ android.view.layoutinflater.createviewfromtag(layoutin
the problemes seems come @ androidmanifest
, don't know where, android:name
seems ok, problem?
thanks helping me !
this bottomline of error.
caused by: java.lang.nullpointerexception: attempt invoke virtual method 'boolean java.io.file.mkdir()' on null object reference
you need insert sd card. see issues tracker.
Comments
Post a Comment