android - Binary XML file line #2: Error inflating class fragment -


i'm trying add map in project cannot because there error when debug application fragment.

this xml file:

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

this .java file:

   import android.os.bundle;    import android.app.activity;     public class mainactivity extends activity {     @override       protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);       }    } 

and, manifest:

 <?xml version="1.0" encoding="utf-8"?>  <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.inkadroid.mapa" android:versioncode="1" android:versionname="1.0" >  <uses-sdk     android:minsdkversion="8"     android:targetsdkversion="19" />  <uses-feature     android:glesversion="0x00020000"     android:required="true"/>  <uses-permission android:name="android.permission.access_fine_location"/> <uses-permission android:name="android.permission.access_coarse_location"/> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.write_external_storage"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices"/>  <meta-data     android:name="com.google.android.gms.version"     android:value="@integer/google_play_services_version" />  <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >        <activity         android:name = ".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>     <meta-data     android:name="com.google.android.maps.v2.api_key"     android:value="my_key"/>  </application>  </manifest> 

also, i've added google_play_services library.

visit http://i61.tinypic.com/2jdjaky.jpg

and, error. if know how solve it, please tell me.

06-02 22:21:50.615: e/androidruntime(869): java.lang.runtimeexception: unable start activity  componentinfo{com.inkadroid.mapa/com.inkadroid.mapa.mainactivity}:  android.view.inflateexception:     binary xml file line #2: error inflating class fragment 06-02 22:21:50.615: e/androidruntime(869):  @    android.app.activitythread.performlaunchactivity(activitythread.java:1647) 06-02 22:21:50.615: e/androidruntime(869):  @  android.app.activitythread.handlelaunchactivity(activitythread.java:1663) 

first need move <meta-data> tag under <application> tag in manifest.xml.

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 

and minsdk="8" should change this

public class mainactivity extends activity 

to

public class mainactivity extends fragmentactivity 

and change this

<fragment xmlns:android="http://schemas.android.com/apk/res/android"       android:id="@+id/map"       android:layout_width="match_parent"       android:layout_height="match_parent"       class="com.google.android.gms.maps.mapfragment"/> 

to

<fragment xmlns:android="http://schemas.android.com/apk/res/android"       android:id="@+id/map"       android:layout_width="match_parent"       android:layout_height="match_parent"       class="com.google.android.gms.maps.supportmapfragment"/> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -