Skip to content Skip to sidebar Skip to footer

Google Map V2 Not Working For Me . Any Sample?

I have used many samples of Google map V2, and i have followed all the things which are necessary for this. But still having problem, only map view is showing and my current locati

Solution 1:

If your manifest file is correct Try this man

activity_main.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><fragmentandroid:name="com.google.android.gms.maps.SupportMapFragment"xmlns:map="http://schemas.android.com/apk/res-auto"android:id="@+id/map"android:layout_width="match_parent"android:layout_height="match_parent"map:cameraTargetLat="33.41662287712097"map:cameraTargetLng="35.21843892856462"map:cameraZoom="4"/></LinearLayout>

In MainActivity.java onCreate()

publicclassMainActivityextendsFragmentActivity  {

private GoogleMap mMap;

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SupportMapFragmentmapFragment= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    GoogleMapmMap= mapFragment.getMap();

    mMap.addMarker(newMarkerOptions()
    .position(newLatLng(35.21843892856462, 33.41662287712097))
    .title("My Office"));

}

Here is the result on my phone enter image description here

Solution 2:

Check whether you add Activate the Google Maps Android API v2 in your Google APIs Console more details can be view in this linkHow to Integrate Google map v2

Solution 3:

The keys to a working Google Maps v2 are

  1. Add the v4 Support library (for older devices) and google-play-services.jar to your project.
  2. Import the google-play-services_lib dummy project as a dependent project. It contains the very important res/ directory with all the localized resources.
  3. Make sure you created a keystore and key and that you are signing your APK with it. If you are using a debug keystore you need to add that to the Google API console.
  4. Test on an Android device NOT the emulator. Google Play Services are not available on the emulator and you will not get a map. You get a white screen in the emulator IIRC.
  5. Check that your AndroidManifest.xml has all the important entries - OpenGL 2, Meta-Key with your key, the permissions, etc.

Solution 4:

After your meta-data that contains the api key you need to add the following lines

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

I suggest you to prove the genymotion emulator that is 20x times better than the default one. Here you can find the instructions to set it correctly:

How do you install Google frameworks (Play, Accounts, etc.) on a Genymotion virtual device?

Post a Comment for "Google Map V2 Not Working For Me . Any Sample?"