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. 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? 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
To know your sha1 you have to open a CMD and do:
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
Now you got your api key go to your Manifest have to put:
... ...
Select the project, right click, go to "File/Import/Android/Existing Android Code into Workspace". 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. Click Finish.
Right click on project go to "Properties/Android"; click on "Add.." button, and choose google play services and click on OK
Add android-support-v4.jar
to your project if isn't yet.
THe layout of the map is:
And the activity that contains the map has to extend FragmentActivity (Something like this)
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!
您是否使用密钥库和软件包名称为应用程序生成了api密钥?
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.