简体   繁体   中英

Map not show on release Android app

I have developed a Android app, this app use Google Maps. On debug version I can see the map but in release mode I cannot see the map only a gray box.

To generate the release version I have use Android Studio (0.8.2) and I follow these steps:

  1. On Android Studio I have use "Build" -> "Generate Signed APK" to start the wizard APK generation;
  2. From the wizard I have generate my release keystore (jks file) then I have generate the APK;
  3. I have use the release keystore with the comamand "keytool -list -v -keystore myreleasekeystore.jks -list" to get SHA1 code;
  4. On Google API Console, under "Apis & Auth" -> "Credensials" on "Public API access", I have change "Key for Android applications" to add a new line like "mySHA1codeFROMrelaseKEYSTORE;nameOFmyAPP", so now I have 2 line (one for debug and one for release);
  5. I don't have change the API KEY on my app because is always the same;
  6. I have upload the app on Google Play, I can download and install it but I cannot see the map;

This is the error on log: "Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors)."

I have also try to generate a new API KEY, replace it on app and regenerate the Signed APK but I get the same result.

I do not find errors in my approach, I read a lot of articles on the internet about this.

Help me because I'm going crazy :)

It is necessary to obtain API key with release SHA-1. Do following steps:

  1. Run keytool -list -v -alias ALIAS_NAME -keystore "PATH_TO_KEY_STORE" -storepass KEY_STORE_PASSWORD -keypass KEY_PASSWORD

All that info from (Build->Generate Signed APK) 生成签名APK

  1. Copy SHA1 from the output

  2. Add new Google Map API key to your project. Use SHA-1 from step 2.

  3. Switch build variant to release

构建变体

  1. Open values/google_maps_api.xml, replace API key with the one from step 2

  2. That's it

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