简体   繁体   中英

Google map not showing when app is downloaded from playstore but showing fine when installed directly signed apk

I am facing an issue in google map.Google map is not showing when I download the apk from google play store but it works fine when I manually install(by transferring to device) same apk which was uploaded to play store.

I have rechecked my debug and release keys which are present here

Please find permission in manifest file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

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

And in Application node:

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

and my java file says:

@Override
public void onMapReady(GoogleMap googleMap) {

    try {

        map = googleMap;
        // it will hide navigation and gps pointer buttons on map
        map.getUiSettings().setMapToolbarEnabled(false);
        //            map.getUiSettings().setZoomControlsEnabled(false);

        if (TextUtils.isEmpty(companyDetailModel.getSupplierCompanyDetailsRS().getResponseDetail().getCompanyDetail().getLatitude())) {


            if (!PermissionUtil.checkPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION)) {

                PermissionUtil.requestPermission(getActivity(), android.Manifest.permission.ACCESS_FINE_LOCATION, LOCATION_PERMISSION_CODE);

            } else {
                map.setMyLocationEnabled(true);

                GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
                    @Override
                    public void onMyLocationChange(Location location) {
                        LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());
                        map.animateCamera(CameraUpdateFactory.newLatLngZoom(loc, 16.0f));
                    }
                };
                map.setOnMyLocationChangeListener(myLocationChangeListener);

            }


        } else {

            LatLng latLng = new LatLng(Double.parseDouble(companyDetailModel.getSupplierCompanyDetailsRS().getResponseDetail().getCompanyDetail().getLatitude()), Double.parseDouble(companyDetailModel.getSupplierCompanyDetailsRS().getResponseDetail().getCompanyDetail().getLongitude()));
            map.addMarker(new MarkerOptions().position(latLng)/*.title("" + companyDetailModel.getSupplierCompanyDetailsRS().getResponseDetail().getCompanyDetail().getAddress())/*.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_launcher))*/);
            map.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14.0f));
        }


        map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
            @Override
            public void onMapClick(LatLng latLng) {
                showFullScreenMap();
            }
        });

    } catch (Exception e) {
        Log.i("LatLng exception", "" + e);
        Utils.showToast(getActivity(), "" + e);
    }

}

I recently Upload the APK on Google Play store and I faced the same issue after checking the Play Console I found the solution for this problem.

Their is no problem with your key but the problem is with your SHA-1. You signed your APK with your SHA-1 that is fine and then upload the APK it also fine.

But as per the new update for Play Console when you signed your APK with SHA-1 and upload the APK it only signed by you but as per the new update it is also signed by Google Play for more security. Have a look here some part of Google Play section:

With Google Play App Signing: You sign your app with your upload key. Then, Google verifies and removes the upload key signature. Finally, Google re-signs the app with the original app signing key you provided and delivers your app to the user.

You can refer Documentation here.

Now, The Answer of your question is After successfully upload the APK you can see that in the section with Two SHA-1 the 1st SHA-1 is Google created its own and 2nd SHA-1 is its yours .

So just copy the Google SHA-1 and paste it to your console where you generate the Google Map API Key.

After a long research about App Signing feature, I came to solution that Google ADDED App Signing feature for app publishing over Google Play. This feature is added due to Keystore mismatch/lost issue faced by all client/developer.

Generally, in new Update of Google Play Developer Console when we upload any apk file over Google Developer , it default provide the service of app signing by Google-Play Self istead Development/Release Keystore has been lost User can update app with new certificate.

App signing key : The key used to sign the APK that's on a user's device. You currently hold the app signing key and use it to sign your APKs. When you complete the program sign-up flow you will upload this key to Google.

Upload key : A new key you generate during your enrollment in the program. You will use the upload key to sign all future APKs prior to uploading them to the Play Console.

So if you accept the App Signing feature during app publishing, then On Google Console you have to provide the Google's App Signing Key SHA-1 key instead of Your uploaded certificate key. So just change it with App Signing SHA-1 Certificate.

You can find App Signing Certificate SHA-1 key from below Tabs.

Google Play Developer Console > Dashboard > Release Management > App Signing .

This is SHA1 key issue .check your google console fingerprint SHA1 thats in release.if your key in debug thats not work in playstore App.

A debug certificate : The Android SDK tools generate this certificate automatically when you do a debug build. Only use this certificate with apps that you're testing. Do not attempt to publish an app that's signed with a debug certificate. The debug certificate is described in more detail in Signing in Debug Mode in the Android Developer Documentation.

A release certificate: The Android SDK tools generate this certificate when you do a release build. You can also generate this certificate using the keytool program. Use this certificate when you are ready to release your app to the world.

For More Details Refer Get API Key and app's SHA-1 fingerprint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM