android


Failed to load map. Error contacting Google servers on fragment


I google two days and still this message. I use debug key to debug
on my nexus 7.
I don't know where is wrong. I have right key,open right api access
but google map on my tablet still blank.
MapsFragment:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView =
inflater.inflate(R.layout.map_fragment,container, false);
container.removeAllViews(); map =
((SupportMapFragment)getActivity()
.getSupportFragmentManager()
.findFragmentById(R.id.map))
.getMap();
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMapFragment = SupportMapFragment.newInstance();
FragmentTransaction fragmentTransaction =
getChildFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.map,mMapFragment);
fragmentTransaction.commit(); return rootView; }
Manifest:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="16" />
<!-- Google Map --> <permission
android:name="com.jertt.xxx.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.jertt.yummymap.permission.MAPS_RECEIVE"/>
<!-- end -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- end -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.jertt.yummymap.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Google Map API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyB54eZnUp8Sw*****" />
<!-- end -->
</application>
map_fragment.xml
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
Not sure if this is your problem or not, but I spend a TON of time trying to figure this one out. Checking the permissions, regenerating api keys. Finally saw a small comment in another answer that worked for me.
Rename your debug.keystore file and then do a clean, and then build. this will generate a new debug.keystore. and a new SHA1 fingerprint. Plug that new fingerprint into the api console and try again.
The other thing you can check is to look at the "reports" section of the api console for the project you are trying to access the api from. If you have tried to run your project and have no traffic for that api, chances are either the SHA1 fingerprint or the package name you gave is wrong. In my case it was the fingerprint.
you have to change to this:
GoogleMap mMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
and also include library to manifest file:
<uses-library
android:name="com.google.android.maps"
android:required="true" />
Your min sdk is 14. No need to use SupportMapFragment. Use MapFragment.
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment.
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
ALso
GoogleMap mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Also missing permissions
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Make sure you have followed all the steps #
https://developers.google.com/maps/documentation/android/
Edit: From the comment
Quoting from the docs
Use MapFragment class only if you are targeting API 12 and above. Otherwise, use SupportMapFragment.

Related Links

How to integrate AWS SQS in my android application [closed]
How to use signed intents in application inter-communication
Android Login with Amazon - did't redirect to app after success Login
Gradle project refresh failed. finished with non-zero exit value 2 with android studio 2.3 on linux bean
Genymotion emulator artifacts in Linux
Start service(alarm manager) on boot_completed AND on app launch if phone was not rebooted for the first time
jdbc.SQLServerDriver working in JAVA Project, and not working in JAVA Android Project
Creating a ImageReader without width/height
Does FirebaseMessagingService run in the background by default?
Lenovo USB driver
Integrated video call app with Android dialer app
Android: What do the users do with my app?
Logout function not clearing ParseUser currentUser after parse migration in Android
How to get URL for an image stored in database in BLOB format
Random Countdown timer
FCM notification is not working after network change (wifi to mobile network)

Categories

HOME
android
httparty
spark-streaming
time-complexity
ggplot2
dns
jax-rs
spring-data-mongodb
hpc
python-multithreading
boto3
title
okhttp
openstreetmap
x-cart
angular-dart
keytool
internationalization
scsi
searchview
job-scheduling
charles
mongoid6
resourcebundle
fable-f#
amazon-quicksight
progress-bar
linked-data
exchangewebservices
panoramas
event-flow
powershell-ise
database-comparison
cart
code-snippets
dsx-desktop
modalviewcontroller
apic
watchman
connection-pool
comparison-operators
azure-arm
show-hide
ntvs
hammer.js
configurationmanager
datamaps
wpas
context-sensitive-grammar
boxing
dt
quicktime
css-transforms
mach-o
universal-analytics
jtree
usart
simplepie
mapxtreme
redbeard-ios
macaulay2
wso2developerstudio
synonym
gogs
shopping
google-query-language
query-by-example
ikiwiki
uiactionsheet
lz77
nupic
nio2
jparsec
sapi
gocql
r-package
ons-api
fuelcms
visual-sourcesafe-2005
aspectj-maven-plugin
fail2ban
rrule
nodelist
execve
primitive-types
spy++
trdion2011
codeplex
lnk
cancellation
grails-plugin-rabbitmq
sphinxql
oocss
beaker-testing
neos-server
ui-select2
facebook-timeline
css-reset
video-codecs
apache-abdera
oracle-enterprise-linux
fsevents
rmdir
facebook-iframe
xpsdocument
product-management
java1.4

Resources

Encrypt Message