简体   繁体   English

调试和发布APK后,Google地图未显示

[英]Google Maps not showing after debug and release APK

How to display Google Maps on my APK? 如何在我的APK上显示Google地图?

I created an Android application with Google Maps. 我使用Google Maps创建了一个Android应用程序。 It works fine on my emulator (I generated an API key on my Google account and pasted it into the "src\\debug\\res\\values​\\google_maps_api.xml " file). 它可以在模拟器上正常运行(我在Google帐户上生成了一个API密钥,并将其粘贴到了``src \\ debug \\ res \\ values \\ google_maps_api.xml ''文件中)。 However, when I try to create a release or debug APK, Google Maps is not displayed. 但是,当我尝试创建发行版或调试APK时,不会显示Google Maps。

Here are the steps I have done : 这是我已完成的步骤:

Step 1: I added a new API_KEY in the release file "src\\release\\res\\values​\\google_maps_api.xml" . 步骤1:我在发行文件“ src \\ release \\ res \\ values \\ google_maps_api.xml”中添加了一个新的API_KEY。

Step 2: I generated a key.jks file with Android Studio (Build -> Generate Signed Package/APK) 步骤2:我使用Android Studio生成了一个key.jks文件(构建->生成签名包/ APK)

Step 3: Then used keytool -list -v -keystore pathToMyKey.jks to get the SHA-1 fingerprint. 步骤3:然后使用keytool -list -v -keystore pathToMyKey.jks获取SHA-1指纹。 I pasted this fingerprint on the SHA-1 section of this API_KEY and added the com.example package name (I did not add a package), 我将此指纹粘贴在此API_KEY的SHA-1部分上,并添加了com.example软件包名称(我没有添加软件包),

Step 4: I built the signed APK, but I can not see Google Maps (the empty screen with a Google logo). 步骤4:我建立了签名的APK,但看不到Google Maps(带有Google徽标的空白屏幕)。

What I tried to debug : 我尝试调试的内容:

I know this subject is common but I can not see where my mistakes are. 我知道这个主题很普遍,但是我看不出我的错误在哪里。 I tried several things to debug, with no results: add the same key to debug/release (and also paste the SHA-1), change the name of the SHA-1 package to com.example.MyApplication.app, create a new API_KEY and starting again ... 我尝试了几件事进行调试,但没有结果:添加相同的密钥以进行调试/发布(并粘贴SHA-1),将SHA-1包的名称更改为com.example.MyApplication.app,创建新的API_KEY并重新开始...

You need to add SHA-1 to Cloud Console project you are using the API in. For debug and unpublished release add the one you get from Android Studio after running signingReport. 您需要将SHA-1添加到正在使用API​​的Cloud Console项目中。对于调试和未发布的版本,请在运行signingReport后添加从Android Studio获得的版本。 If you are publishing the app and using Play Console signing you also need to add that SHA-1 as well. 如果您要发布应用程序并使用Play控制台签名,则还需要添加该SHA-1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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