I know this is a duplicate question, but solutions from previous post doesn\'t worked for me. Thats why am asking this question.
I am tryi
I have download your project from git and after checking i found that you have missed a line which is required to display map Fragment.
Replace your main activity code with the following code:-
public class MainActivity extends FragmentActivity {
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
Please add these line in your manifest file
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your Goolge API key" />
After API 11+, I think you now have have to replace your MapFragment
by SupportMapFragment
. It would be something like:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
Take a look here for further information. Let me know how are you going with.
This could happen also if you did not define API_KEY for google maps in your manifest file.
It looks like this:
`....
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="<your key>" />
....`
Create your key in Google Developer Console