DroidEngineer
DroidEngineer

Reputation: 467

Google map not showing on android (signed apk) with Google V2 release key

I am exactly following step Given here. API key is obtained by following steps Here i already upload the apk on market for test purpose but still its not showing map although it display map with debug key.but when i try to use release Google map key its showing white screen with zoomin and zoomout button but no maps.

Google play store link

MapFragment

public class CustomMap extends SupportMapFragment {

private static final int ZOOMIN_ANIMATION_DURATION = 300;

public static CustomMap newInstance() {
    Bundle bundle = new Bundle();
    CustomMap customMap = new CustomMap();
    customMap.setArguments(bundle);
    return customMap;

}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

}

@Override
public void onResume() {
    super.onResume();
    GoogleMap googleMap = getMap();
    if (googleMap == null) {
    } else {
        LatLng mLatLng = new LatLng(70.00,
                33.00);

        googleMap.addMarker(new MarkerOptions()
                .title("Title")
                .snippet("Address")
                .position(mLatLng)
                .icon(BitmapDescriptorFactory
                        .fromResource(R.drawable.ic_launcher)));
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(mLatLng));
        googleMap.animateCamera(CameraUpdateFactory.zoomBy(10),
                ZOOMIN_ANIMATION_DURATION, null);
    }
}

}

Main Activity

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@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;
}

}

XML

<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" >

<fragment
    android:id="@+id/fragment1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    class="com.example.maptest.CustomMap" 
  />

</RelativeLayout>

Manifest

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

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

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" >
</uses-permission>
<uses-permission android:name="com.baresso.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"   />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.maptest.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="AIzaSyDcAy3bEVhv_lhAH1hHNHk_RpvyXiN0xNI" />
</application>

</manifest>

Upvotes: 0

Views: 2640

Answers (4)

Ravinder Kumar
Ravinder Kumar

Reputation: 1

copy SHA1 from logcat when you siged your apk click on finish and add this on your google play developer console project SHA-1 certificate fingerprint this will show your map with signeg apk

Upvotes: 0

mn0102
mn0102

Reputation: 849

problem's lying here

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

replace it with giving your own package name..

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

and here

replace this

<uses-permission android:name="com.baresso.permission.MAPS_RECEIVE" />
with <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE" />  

Upvotes: 0

Aarun
Aarun

Reputation: 564

https://developers.google.com/maps/documentation/android/start

  1. I think the problem is with the Obtaining an API Key Or With The SHA-1 Finger Print.
  2. have You Give the application Package with the SHA-1 fingerprint in the Google Consol
  3. install Google Play Service into Your Emulator or Android Device.
  4. Please prefer Android Device for Map Testing .

Upvotes: 1

Yatin Goswami
Yatin Goswami

Reputation: 31

Google Maps Will not work with the latest change in their policies which limits the usage of google map libraries directly.

To solve this either you have to include entire google maps as a third party plug in or you can display the google map in an webview and pass locations through a javascript html function.

for ex:--

<script>
function initialize()
{
document.getElementById('dummyDIV').innerHTML = '<div id="googleMap"     
style="width:'+screen.width+'px;height:'+screen.height+'px;"></div>';
var sURL1 = window.document.URL;
var sURL2 =sURL1.split("%20");
var sURL= sURL2[0];
for (j=1;j<sURL2.length;j++){
    sURL = sURL+' '+sURL2[j];
} 

var mapProp = {
  center:new google.maps.LatLng(19.155721,72.856025),
  zoom:10,
  disableDefaultUI:true, 
  zoomControl:true,
  mapTypeControl:true,
  mapTypeId:google.maps.MapTypeId.ROADMAP

  };

var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);


   if (sURL.indexOf("?") > 0)
{
var bifurcatedURL = sURL.split("?");    

var everyMarker = bifurcatedURL[1].split("&");  
for (i=0;i<everyMarker.length;i++)
    {
        var markerDetails =everyMarker[i].split("+");
        var lat = (markerDetails[0]);
        var lon = (markerDetails[1]);
        var address =markerDetails[2];
        var type = markerDetails[3];
        var markerPosition = new google.maps.LatLng(lat,lon);
        map.setCenter(markerPosition);
        if(type=='a'||type=='A')
    var marker=new 
google.maps.Marker({position:markerPosition,icon:'atm_marker.png'});
        else if(type=='b'||type=='B')
 var marker=new google.maps.Marker
 ({position:markerPosition,icon:'branch_marker.png'});
        else if(type=='c'||type=='C')
var marker=new google.maps.Marker({position:markerPosition,icon:'pin_blue.png'});

            marker.setMap(map);
    var infowindow = new             google.maps.InfoWindow({content:address});
            listenMarker(marker,address,infowindow,map)
    }
}   
}

function listenMarker (marker,address,infowindow,map)
{
// so marker is associated with the closure created for the listenMarker function call
google.maps.event.addListener(marker, 'click', function() {
                    infowindow.open(map, marker);
                });
}

 google.maps.event.addDomListener(window, 'load', initialize);
</script>

Upvotes: 1

Related Questions