these are my codes , I'm programming for android api 8+ . I wanna to show the location on the map , I'm using google map api 2 , I've imported google-play-services_lib and the jar file exits . I've a swipe tab and it contains 3 fragment . here are my code
swipe tab Layout
<FrameLayout 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"
tools:context=".Spots_tab2"
android:background="#cccc00"
>
<fragment
android:id="@+id/map"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:name="com.google.android.gsm.maps.SupportMapFragment"
/>
Swipe tab fragment:
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.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class Spots_tab2 extends Fragment {
private GoogleMap map;
private LatLng location;
public Spots_tab2() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
return inflater.inflate(R.layout.spots_tab2, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
map = ((SupportMapFragment)getActivity().getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
location= new LatLng(31.15016,51.20188);
map.addMarker(new MarkerOptions().position(location).title("semirom"));
CameraUpdate update= CameraUpdateFactory.newLatLng(location);
update = CameraUpdateFactory.newLatLngZoom(location, 10); // zooom
map.animateCamera(update);
}
}
manifest :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<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" />
<permission
android:name="com.example.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.maps.permission.MAPS_RECEIVE" />
<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/Theme.AppCompat.Light" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAWOjtGwFaWIL4JQqJfrpwoxS1Mx7oMDsk" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
this is the error :
unable to instantiate fragment com.google.android.gsm.SupportMapFragment: make sure class name exists ,is public, and has empty construct or that is public
something else , this is how I import google play service , I imported google-play-services as a project in my workspace and then add it as a library to my project
Could you please help me thanks