java - Error inflating class fragment ( android.view.InflateExpection ) -


so trying incorporate google map in fragment, have followed steps mentioned on google dev docs on maps, error in inflating class fragment. went through many stacks , did mentioned in them, error persists. here's map fragment,

fragment_two.java

    package com.example.theweddingapp;  import com.google.android.gms.maps.cameraupdate; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.mapview; import com.google.android.gms.maps.mapsinitializer; 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;  import android.content.context; import android.os.bundle; import android.support.v4.app.fragment; import android.support.v4.app.fragmentactivity; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup;  public class fragmenttwo extends fragment implements onmapreadycallback {      mapview mapview;     googlemap map;      public static fragment newinstance(context context) {         fragmenttwo f = new fragmenttwo();         return f;     }       public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) {         viewgroup root = (viewgroup) inflater.inflate(r.layout.fragment_two, null);         getactivity().setcontentview(r.layout.fragment_two);         mapfragment mapfragment = (mapfragment) getactivity().getfragmentmanager().findfragmentbyid(r.id.map);             mapfragment.getmapasync(this);         return root;     }     @override     public void onmapready(googlemap map) {         map.addmarker(new markeroptions()             .position(new latlng(0, 0))             .title("marker"));     }   } 

my map xml,

fragment_two.xml

    <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:orientation="vertical" > <fragment android:name="com.google.android.gms.maps.supportmapfragment"     android:id="@+id/map"     android:layout_width="match_parent"     android:layout_height="match_parent"/> </relativelayout> 

here's manifest

androidmanifest.xml

    <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.theweddingapp"     android:versioncode="1"     android:versionname="1.0" >      <permission         android:name="com.example.theweddingapp.permission.maps_receive"         android:protectionlevel="signature" />      <uses-permission android:name="com.example.theweddingapp.permission.maps_receive" />       <uses-sdk         android:minsdkversion="14"         android:targetsdkversion="17" />      <uses-permission android:name="android.permission.access_network_state" />     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" />     <uses-permission android:name="android.permission.write_external_storage" />      <!-- required show current location -->     <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" />      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >             <meta-data         android:name="com.google.android.gms.version"         android:value="@integer/google_play_services_version" />             <meta-data      android:name="com.google.android.maps.v2.api_key"      android:value="aizasybtbyjkzydeefgsljsolbr54riajhwcvjg" />         <activity             android:name="com.example.theweddingapp.mainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>       </application>  </manifest> 

here's logcat

        01-27 21:43:09.811: e/androidruntime(15412): fatal exception: main     01-27 21:43:09.811: e/androidruntime(15412): process: com.example.theweddingapp, pid: 15412     01-27 21:43:09.811: e/androidruntime(15412): android.view.inflateexception: binary xml file line #6: error inflating class fragment     01-27 21:43:09.811: e/androidruntime(15412):    @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:713)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.view.layoutinflater.rinflate(layoutinflater.java:755)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.view.layoutinflater.inflate(layoutinflater.java:492)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.view.layoutinflater.inflate(layoutinflater.java:397)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.view.layoutinflater.inflate(layoutinflater.java:353)     01-27 21:43:09.811: e/androidruntime(15412):    @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:290)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.app.activity.setcontentview(activity.java:1937)     01-27 21:43:09.811: e/androidruntime(15412):    @ com.example.theweddingapp.fragmenttwo.oncreateview(fragmenttwo.java:35)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.fragment.performcreateview(fragment.java:1460)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.os.handler.handlecallback(handler.java:733)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.os.handler.dispatchmessage(handler.java:95)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.os.looper.loop(looper.java:136)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.app.activitythread.main(activitythread.java:5086)     01-27 21:43:09.811: e/androidruntime(15412):    @ java.lang.reflect.method.invokenative(native method)     01-27 21:43:09.811: e/androidruntime(15412):    @ java.lang.reflect.method.invoke(method.java:515)     01-27 21:43:09.811: e/androidruntime(15412):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785)     01-27 21:43:09.811: e/androidruntime(15412):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601)     01-27 21:43:09.811: e/androidruntime(15412):    @ dalvik.system.nativestart.main(native method)     01-27 21:43:09.811: e/androidruntime(15412): caused by: java.lang.illegalargumentexception: binary xml file line #6: duplicate id 0x7f080035, tag null, or parent id 0x0 fragment com.google.android.gms.maps.supportmapfragment     01-27 21:43:09.811: e/androidruntime(15412):    @ android.support.v4.app.fragmentactivity.oncreateview(fragmentactivity.java:285)     01-27 21:43:09.811: e/androidruntime(15412):    @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:685)     01-27 21:43:09.811: e/androidruntime(15412):    ... 22 more 

update #1

implemented replies post, still getting null pointer error when calling map. somehow cannot hold of map. error mapfragment.getmapasync(this); here's logcat after updating:

    01-27 23:04:50.140: e/androidruntime(21288): fatal exception: main 01-27 23:04:50.140: e/androidruntime(21288): process: com.example.theweddingapp, pid: 21288 01-27 23:04:50.140: e/androidruntime(21288): java.lang.nullpointerexception 01-27 23:04:50.140: e/androidruntime(21288):    @ com.example.theweddingapp.fragmenttwo.oncreateview(fragmenttwo.java:36) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.support.v4.app.fragment.performcreateview(fragment.java:1460) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:911) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1088) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1444) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.support.v4.app.fragmentmanagerimpl$1.run(fragmentmanager.java:429) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.os.handler.handlecallback(handler.java:733) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.os.handler.dispatchmessage(handler.java:95) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.os.looper.loop(looper.java:136) 01-27 23:04:50.140: e/androidruntime(21288):    @ android.app.activitythread.main(activitythread.java:5086) 01-27 23:04:50.140: e/androidruntime(21288):    @ java.lang.reflect.method.invokenative(native method) 01-27 23:04:50.140: e/androidruntime(21288):    @ java.lang.reflect.method.invoke(method.java:515) 01-27 23:04:50.140: e/androidruntime(21288):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:785) 01-27 23:04:50.140: e/androidruntime(21288):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:601) 01-27 23:04:50.140: e/androidruntime(21288):    @ dalvik.system.nativestart.main(native method) 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -