[英]Fix the Failed to load map. Could not contact Google servers.
I am using the map functionality in my app.Whenever I run map in my app I got error ie 我在我的应用程序中使用地图功能。每当我在我的应用程序中运行地图时,我得到错误即
04-19 11:03:50.274: E/Google Maps Android API(23366): Failed to load map. Could not contact Google servers.
I have checked manifest file and code all is correct.And Google play service is also working in my android device. 我已经检查了清单文件和代码都是正确的。谷歌播放服务也在我的Android设备上工作。 I am running sample code of map same error I have got.But I am not understanding what is exact problem.Please suggest me how to fix that problem.
我正在运行地图的示例代码同样的错误我有。但我不明白究竟是什么问题。请建议我如何解决这个问题。 `
`
Have you adquire your map-key in Google Api Console using the package name of your project and your SH1 of the Keytore? 您是否使用项目的包名和Keytore的SH1在Google Api控制台中获取了地图密钥? If not, go to console and do it ;) You have to put this key in your Manifest, and the permissions required.
如果没有,请转到控制台并执行;)您必须将此密钥放在您的清单中,并且需要权限。
Normally this error happens when: 通常在以下情况发生此错误:
===============Mini tutorial===================== ===============迷你教程=====================
Ex: 48:+4: ... :46;com.xxxx.xxx.xxx
Ex: 48:+4: ... :46;com.xxxx.xxx.xxx
To know your sha1 you have to open a CMD and do: 要了解你的sha1,你必须打开一个CMD并执行:
C:\\>cd C:\\Users\\YOURUSER\\.android\\ C:\\Users\\YOURUSER\\.android>"C:\\Program Files\\Java\\jdkXXXX\\bin\\keytool.exe" -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android
XXX Means the version you have XXX表示您拥有的版本
Now you got your api key go to your Manifest have to put: 现在你得到你的api密钥去你的Manifest必须放:
... ... ......
Select the project, right click, go to "File/Import/Android/Existing Android Code into Workspace". 选择项目,右键单击,转到“文件/导入/ Android /现有Android代码到工作区”。 In the root directory go to
"<-sdk-android folder> /extras/google/google_play_services/libproject/google-play-services_lib"
and select the project that appears. 在根目录中,转到
"<-sdk-android folder> /extras/google/google_play_services/libproject/google-play-services_lib"
并选择出现的项目。 Click Finish. 单击完成。
Right click on project go to "Properties/Android"; 右键单击项目转到“属性/ Android”; click on "Add.." button, and choose google play services and click on OK
点击“添加..”按钮,然后选择Google Play服务并点击“确定”
Add android-support-v4.jar
to your project if isn't yet. 如果还没有,请将
android-support-v4.jar
添加到您的项目中。
THe layout of the map is: 地图的布局是:
And the activity that contains the map has to extend FragmentActivity (Something like this) 包含地图的活动必须扩展FragmentActivity(像这样的东西)
public class MainActivity extends android.support.v4.app.FragmentActivity {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } ... }
AAAAND thats all! AAAAND就是这样!
您是否使用密钥库和软件包名称为应用程序生成了api密钥?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.