發布不顯示谷歌地圖的 APK 文件 (Release APK file not showing google maps)


問題描述

發布不顯示谷歌地圖的 APK 文件 (Release APK file not showing google maps)

我應用了谷歌開發者文檔中提到的確切步驟來創建一個示例谷歌地圖項目,並且在模擬器上一切正常,但是當我生成項目 apk 文件並在真實設備上啟動它時三星 Galaxy S4 谷歌地圖沒有'不顯示它只顯示一個空白背景,僅在屏幕左下角出現彩色的 Google 徽標!!

我為谷歌地圖創建了新項目我為該項目創建了新的 .jks 文件並創建了商店和密鑰傳遞和別名然後我從 cmd java bin 中提取 SHA1 我去 dev.google.com/console 創建了新項目然後啟用 google maps android API 然後從 Credentials 創建 API 密鑰 將此 API 密鑰粘貼到 google_maps_api.xml 中我的項目使用 .jks 文件路徑和別名以及兩個密碼更新了 signingConfigs 版本。然後從 Android Studio 生成簽名的 APK 然後將 app‑release.apk 傳輸到真實設備然後安裝它同樣的問題谷歌地圖不顯示。


參考解法

方法 1:

Reason for this issue

This occurred because there are different SHA1s in debug and release types.

Fix for this issue

Add the SHA1 of the keystore used to build the release APK to Google console

Steps:

  1. Get the path of the keystore when you generate signed APK

    Build ‑‑‑‑> Generate Signed APK..

Save the key store path

enter image description here

Remember to make Build Type ‑‑‑ release

enter image description here

  1. Extract SHA1 from the keystore.

Open your terminal use command below:

 keytool ‑list ‑v ‑keystore "/Users/NT/Desktop/generalkey.jks"

You will be asked for password for your keystore.

Change path to your keystore path keytool ‑list ‑v ‑keystore "keystore path"

From the Certificate fingerprints, you will see the SHA1

  1. Generate android key using this SHA1 and your package name

enter image description here

Generate APK using keystore and enjoy your map

方法 2:

It might be silly but I had my API key included in

app\src\debug\res\values\google_maps_api.xml (debug)

You also need to include in‑

app\src\release\res\values\google_maps_api.xml (release)

方法 3:

if any one still facing this problem :

this happend to me because we need two google maps api keys one for the debug and another one for the release, you can check in :

C:\Users\username\AndroidStudioProjects\yourapp\app\src\ debug \res\values and you'll find an xml with your api key like:

    <string name="google_maps_key" templateMergeStrategy="preserve" 
          translatable="false">AIza...etc</string>

but if you check here:

C:\Users\username\AndroidStudioProjects\yourapp\app\src\ release \res\values you will find an xml but without api key inside like:

     <string name="google_maps_key" templateMergeStrategy="preserve" 
         translatable="false">YOUR_KEY_HERE</string>

it was noted as a comment inside the xml file itself :

Before you release your application, you need a Google Maps API key.

To do this, you can either add your release key credentials to your existing
key, or create a new key.

Note that this file specifies the API key for the release build target.
If you have previously set up a key for the debug target with the debug signing certificate,
you will also need to set up a key for your release certificate.

Follow the directions here:

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

Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.

方法 4:

Check the following things:

  • This below file should be in both debug and release

    app\src\debug\res\values\google_maps_api.xml (debug)
    

    You also need to include in

    app\src\release\res\values\google_maps_api.xml (release)
    
  • Add the SHA1 for release apk into Google Api Console. You can get SHA1 key from play console >> App Signing >> SHA1 Certificate

方法 5:

Another additional step: In google play developer console add App Signing SHA1 fingerprint: enter image description here

(by user2985035Mina FawzyVarun KumarehabGovind PrajapatiNELSON RODRIGUEZ)

參考文件

  1. Release APK file not showing google maps (CC BY‑SA 2.5/3.0/4.0)

#apk-expansion-files #Android #android-keystore






相關問題

從擴展文件播放聲音文件 (Playing sound files from expansion file)

如何掛載加密的APK擴展文件? (How to mount encrypted APK expansion files?)

如何使用jobb工具Android創建OBB文件 (How to create OBB files USING jobb tool Android)

發布不顯示谷歌地圖的 APK 文件 (Release APK file not showing google maps)

PHP - 上傳APK到自己的服務器 (PHP - upload APK to own server)

如果從 Google Play 商店下載 apk 和 obb,則無法在 android 10 設備上訪問 obb 擴展文件 (Cannot reach obb expansion file on android 10 device if apk and obb is downloaded from Google Play store)

APK 擴展文件下載顯示驗證的各種進度 (APK Expansion File Download shows various progress on validation)

APK 擴展文件下載不起作用 (APK Expansion file download doesn´t work)

掛載 .obb 時未調用 OnObbStateChangeListener (OnObbStateChangeListener not called when mounting .obb)

可以掛載未加密的obb但加密錯誤21 (can mount unencrypted obb but with encrypted error 21)

無法在魅族 m3 note 上掛載 .obb 文件(state = 21) (Can't mount .obb file (state = 21) on Meizu m3 note)







留言討論