1

i trying to run google map in actual device has android version 4.0.3 ICE sandwitch, i read many tutorials and every settings are ok like : installtion of google play sevices in SDK manger. importing google play services lib in my application. getting google map API key.

the manifest file code is looks like:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.google_map_application"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="13"
    android:targetSdkVersion="15" />

<permission
    android:name="com.example.google_map_application.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>

<uses-permission android:name="com.example.google_map_application.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission          android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<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.maps.v2.API_KEY"
        android:value="AIzaSyCoIsr6NxAH_J3NLtkh5YSxQGZAq1gvWW8" />
    <activity
        android:name="com.example.google_map_application.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>

the Xml file code is looks like:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

the main activity code is:

package com.example.google_map_application;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends Activity{
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main);

    mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); 
    final LatLng CIU = new LatLng(35.21843892856462, 33.41662287712097); 
    Marker ciu = mMap.addMarker(new MarkerOptions() .position(CIU).title("My Office"));


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;

}

}

this error is continuously appears:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.google_map_application/com.example.google_map_application.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class fragment.

Mohsen Ali
  • 655
  • 1
  • 9
  • 30

2 Answers2

1

Try to change Target SDK something similar to your Google Play Service library version for example:

<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="17" />
Ayman Al-Absi
  • 2,630
  • 24
  • 22
0

match the android:targetSdkVersion with the same version of api you have downloaded, for example change it to 17 if you have downdloaded google api 17.

Manisha Bano
  • 1,853
  • 2
  • 22
  • 34