I have read all the similar questions and did everything that was described in them, but did not help.
Google Maps API v2 is Enabled and
API key is correct
I just chose GoogleMapsActivity in "New project", then created a key.jks, created sha1 by keytool, created public api access key, put my API key in manifest.
I tried:
clean-rebuild-unistall app-install
updated api key many times
create a new project with the new key.jks (and all over again)
delete and create api key
Here is my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dandewine.user.thinkmobiletest" >
<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 ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIza**************************" />
<activity
android:name=".ActivityMain"
android:label="#string/title_activity_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Here is my activity:
public class ActivityMain extends FragmentActivity implements OnMapReadyCallback {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_map);
SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(0, 0))
.title("Marker"));
}
Logcat:
E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
07-27 14:52:37.551 25002-25035/com.dandewine.user.thinkmobiletest E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIza****************************
Android Application (<cert_fingerprint>;<package_name>): 8C:2B:4C:F7:CF:FB:EC:D5:DC:D7:D0:5D:6E:30:49:74:97:18:57:88;com.dandewine.user.thinkmobiletest
UPDATE: I have different SHA1 fingerprints in google dev. console and in logs, how to deal with that?
Can anyone help with advice.
It sounds like you're using the SHA1 fingerprint from the keystore that you will be using to generate a signed apk.
For debugging/running from Android Studio, you need to use the SHA1 fingerprint that Android Studio uses to sign the apk.
Note that you can get this SHA1 fingerprint by using command line:
For Mac or Linux:
keytool -list -v -keystore ~/.android/debug.keystore
For Windows:
keytool -list -v -keystore C:\User\YourUser\.android\debug.keystore
with password "android".
However, since you already have the correct value in your logs,
just copy this from your logs (I modified it here, don't copy from here):
8C:2B:4C:F7:CF:FB:EC:D5:DC:D7:D0:5D:6E:30:49:xx:xx:xx:xx:xx;com.dandewine.user.thinkmobiletest
And paste that into your API Key in the developer console.
You can add multiple fingerprint/package values to each API key, one per line (you can also see that in the instructions when you are editing an API key).
You can also configure a different API key for debug and release, if you do that take a look at this answer.
add the following in manifest:
<permission
android:name="com.dandewine.user.thinkmobiletest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.tp.lib.tp.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
also:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
Check if you have included your signature key in debug and release mode, read this: http://developer.android.com/tools/publishing/app-signing.html#cert
Related
I have developed an android app for my company, where I have introduced a map in a fragment.
The app works fine on my phone, but when providing this app to other fellow workers, in their phones the map is not showing, it appears the focus buttons and the Google logo, but that's it, no map.
layout
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
class="com.google.android.gms.maps.SupportMapFragment"/>
manifest
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<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"/>
<!-- 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"/>
...
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyArrfA3PQ9kVcwucUGZCoc9yMUC9wc2g_4"/>
Fragment
/*Try to obtain the map from the SupportMapFragment*/
mMap = ((SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
it's a debug key problem.
you must use a release key.
With version 2 API's you can use the same key for release and debug. In your google api's console edit your allowed android apps and on each line put your debug/release key, and then your app name. You can use multiple lines, then it will work with both keys.
In Google Developer API Console
Click on Create New Android key...
In cmd.exe/Terminal: keytool -list -v -keystore mystore.keystore
Password: android
Now enter SHA1 key;package name for debug and press enter
Enter SHA1 key;package name for release
Click on Create
Now use this API key your project
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/common_map_api_key"/>
I'm getting a white screen on my google maps app - zoom buttons are showing. I'm revisiting code I wrote last year that worked fine so it should all be ok. I'm testing on a gingerbread 2.3.3 phone.
I have google maps v2 enabled
I have a matching api key in my manifest: AIzaSyCKzmEns8anNV3QLLBRIw3f88Y7TmsXXXX
I have the correct hash/domain in use for my debug:
D6:35:00:83:CD:F6:2F:69:44:FB:D2:9E:AE:DE:F0:1B:27:01:1D:FF;com.example.androidac_session8a
In my project I have google-play-services-lib linked
I have the google APIs SDK downloaded and set as the target
In my code I check that a googlemap object is returned, which it is and inside logcat there are no errors generated
My manifest is ok as far as I know:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.androidac_session8a.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>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyCKzmEns8anNV3QLLBRIw3f88Y7TmsXXXX"/>
</application>
My layout is inside a tabbed view but here is the xml:
<fragment
android:id="#+id/worldmap"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Here is the code to initialise the map. I have additional code to update it to show satellite and draw stuff but I've removed that.
private void initialiseMap() {
//get the fragment and call getMap on it which returns a GoogleMap
if (googleMap == null) {
googleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(
R.id.worldmap)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(activity.getApplicationContext(),
"Unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
debug keystore may expire within 1 year. Though there is no fix time limit. As you told that your code is one year old, so i think your key has expired. So better create new apikey. And usually white screen problem is occurred for wrong api key.
Open your terminal and execute the following command to generate SHA-1 fingerprint.
On Windows
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
On Linux or Mac OS`
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
and using this SHA-1 fingerprint create new api key
It's so bad I could cry ;)
I went on holiday and turned off packet data.
I have wifi on but at work my wifi hotspot is flaky at best yet wifi stays on but does nothing.
I enabled packet data and it worked.
3 hours I've spent reinstalling eclipse, google play library, regenerating keys....
I had a similar problem but I doubt you would have the same problem but anyways give it a try . I set the default LatLng to zoom to at the start of the map to (0,0) and a very high zoom level . so I was seeing a desert at a high zoom level which seemed like map didn't load at all.
So try zooming out of the map or try explicitly setting the latLng and zoom level at the start of the map.
I am making an android app with google maps:-
My steps:-
Main activity extends Fragment activity
Made a copy of Google play services library and imported it to eclipse.Further added a reference of the library to the project.
Enabled the build target of the project to Google API's 4.4.2
Created a browser key on Google API console.
Created an SHA1 certificate for the app in eclipse using the keytool plugin(Also verifies the key using the traditional command prompt technique and both match).
Created an android Api key on Google API console using the SHA1 key obtained
Issue:- I get a blank map on the screen with the zoom in and zoom out buttons
Here is my code:-
activity_main.xml:-
<fragment
class="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/spr_place_type"
/>
AndroidManifest.xml :-
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<permission
android:name="com.strangeworld.locations.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-library
android:name="com.google.android.maps"/>
<activity
android:name="com.strangeworld.locatorapp.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD2LVShEdbQWWV4......"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Log cat:-
01-10 10:33:28.059: E/dalvikvm(2440): Could not find class 'maps.ae.i', referenced from method maps.af.al.a
01-10 10:33:30.039: E/GooglePlayServicesUtil(2440): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
01-10 10:33:32.909: E/Google Maps Android API(2440): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-10 10:33:32.929: E/Google Maps Android API(2440): Ensure that the following correspond to what is in the API Console: Package Name: com.example.locations, API Key: AIzaSyAZhJllASbTnr......, Certificate Fingerprint: 83033D1ECACA2C88F9AA2.....
While generating the key do i need to spicify the whole package name i.e. com.abcdm.locatorapp or just com.abcdm
Yes you need to mention the package name in the google api console
SHA;complete packagename
Also try regenerating the key
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included
You need to reference the google play servies properly. Check this
Importing google-play-service library showing a red X next to this reference android
Your keystore is not appropriate or package name mistake in google api console, recheck once.
Which type of keystore you are using? If you use debug key and published map looks blank. Use release key to publish.
Google Map Android API v2 can't display map in play store application
mention the entire package name with the key after semicolon ie. com.abcdm.locatorapp
i am trying to integrate Google Maps to my Android Application. I followed this tutorial: https://blog-emildesign.rhcloud.com/?p=435.
I did everything as suggested.
These are the errors in the error log:
E/Google Maps Android API(28238): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
E/Google Maps Android API(28238): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
E/Google Maps Android API(28238): Ensure that the following correspond to what is in the API Console: Package Name: com.example.kontrollen, API Key: xxxxxxxxxxxxxx, Certificate Fingerprint: xxxxxxxxxxxxxxxxxxxxxxx
And this is my google account:
Do you have any ideas what i can do?
This is my AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.kontrollen"
android:versionCode="1"
android:versionName="1.0" >
<permission android:name="com.example.kontrollen.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.kontrollen.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxx" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.kontrollen.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>
</application>
</manifest>
I solved the problem by uninstalling the app and cleaning the project folder. I did not change anything. Thank you for your help.
follow the url to create your app google api key i have done this recently.. and it was successful.
https://code.google.com/apis/console/ ------------ For Google API
https://developers.google.com/maps/documentation/android/start ------------ Crate Map
read these page carefully every thing is given in this page .. follow the same but make sure you have generated correct SHA1 fingerprint
and when you are going to crate the app make sure run it on real device because it need google play services to run add google pay services in your application
Edited answer:
Try putting the meta-data within the application tag, preferably right before the closing tag like
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="xyz" />
</application>
Follow this steps to trace error youself
STEPS
for your error type
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
1.check for internet or gsf reader permissions in manifest as shown above.
2.check for the package name you used in you manifest.
3.check in your api console the service that you started is Google Maps Android API v2.
4.Check the library google play services is imported or not.
5.if no solution is working try out new way following this link-- https://developers.google.com/maps/documentation/android/start.
6.Also keytool command to generate sha1--i used is-
keytool -v -list -alias androiddebugkey -keystore C:/Users/username/.android/debug.keystore
I had actually made a maps activity from the studio and used the link it generated to set up the maps API. Where I went wrong was, I placed it inside a package and the package name that was registered for the app was with that folder name. For Ex.
If app package name is
com.awesome.shit
the package that was saved in API was
com.awesome.shit.maps
changed it and it started working.
I have checked and double checked my APIkey that I registered on the Google Console however I am still getting the following error:
12-05 16:31:12.940: E/Google Maps Android API(12334): Failed to load map. Could not contact Google servers.
What I am seeing is the zoom in/out buttons and the background for the MapView but no Map???!!!
Any ideas???
Answer
I will post it here because what solved my issue was stated in the comments of the accepted answer below.
It was the READ_GSERVICES permission. For some reason the permission wasn't mentioned on the developer site when it came to using them.
For setting up Google Maps API v2 on Android, make sure that you have completed all of the following steps.
App Key For API Access
When Google asks for the SHA1 fingerprint of your app certificate, you will want most likely want to run this twice, once for your debuging certificate, and once for your publishing certificate.
keytool -list -v -keystore publishcert.keystore
keytool -list -v -keystore ~/.android/debug.keystore
The fingerprint of the app on the market is different then the fingerprint of an app that you are just testing!
Enable the service on the Google API Console
Login to the Google API Console.
On the services page, find Google Maps Android API v2.
Note - Google Maps API v2 is DIFFERENT then Google Maps Android API v2
In the API Access tab, click Create new Android Key
Add your certificate signatures for access to the APIs.
yourrelease-fingerprint;com.example.project.package
yourdebug-fingerprint;com.example.project.package
You will be provided with a generated API Access Key.
You may need to first create an API Project in the API Console
Amend the App Manifest
Add your API Key, inside of the <application> element.
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="yourapikey"/>
Add the following permissions:
<permission
android:name="com.example.project.package.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.project.package.permission.MAPS_RECEIVE"/>
<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"/>
Add the following feature request:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
Make sure all below mentioned points are taken care:
1) Wrong service was enabled. Make sure the "Google Maps Android API v2", not "Google Maps API v2" is enabled and re-generate the API key.
2) Add the following elements to your manifest. Replace com.example.mapdemo with the package name of your application.
3) Use of correct certificate and key. Release certificate, which WILL NOT WORK during debugging when you run the app on my phone. You have to use the debugging keystore certificate fingerprint instead.
It could be an issue with the Manifest. The following works for me, specifically permission.MAPS_RECEIVE solved a similar issue I had: zoom buttons and myLocation displayed, but map had no tiles...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.discos2.example"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.discos2.example.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.discos2.example.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature
android:name="android.hardware.location"
android:required="false" />
<uses-feature
android:name="android.hardware.location.network"
android:required="false" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature
android:name="android.hardware.wifi"
android:required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:hardwareAccelerated="true">
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="__NEW_GOOGLE_MAPS_V2_KEY_GOES_HERE__" />
<activity
android:name=".ui.activities.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
BTW, I'm running Windows 7. I fussed over this for days, until I discovered the following:
I have more than one debug.keystore.
One is at:
C:\android-sdk\.android\debug.keystore
And there's another, at:
C:\Users\David\.android\debug.keystore
Once I found the "C:\Users\David.android\debug.keystore" I did:
keytool -list -alias androiddebugkey -keystore C:\Users\David\.android\debug.keystore -storepass android -keypass android -v
I submitted the resulting SHA1 to google console and got an API-key that works.
Getting the SHA1 from the keystore at "C:\android-sdk.android\debug.keystore" does not work.
I was facing the same issue ; but for me it was keystore issue I was signing it with debug keystore hence Google map api v2 was not able to connect to Google map.
I created a new api key using my-release-keystore.keystore (u can find it at C:\Users\{YOUR_USER_NAME}\.android\my-release-key.keystore) generate SHA1 using keytool available in JDK; copy it and register with google console.
Use api key generated in your applications manifest file. Sign it with my-release-key.keystore will pushing it on device.
You might have enabled the wrong service "Google Maps Android API v2", not "Google Maps API v2"
I had the same problem. I just simply missed this point:
When you list your Google APIs services, there are three Google Maps API available.
Google Maps Android API v2
Google Maps API v2
Google Maps API v3
...
Check that you have Android version (Google Maps Android API v2) enabled, when you code for Android.
Google Maps API v2 was not good enough.
Just create new API key with SHA and most importantly correct package name (like com.example.mapdemo). Use the new generated key in your AndroidManifest.xml.
I guess we need new API key for all new eclipse projects which uses Google maps (as creating new key also requires the package name, which is essentially different for all projects).
After spending many hours, the problem had been eventually solved:
if none of the above helped you solving your problem,
try to put your api key into values/strings.xml
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="#string/map_key"/>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="map_key">YOUR_KEY</string>
</resources>
I did everything what was required to achieve this task. My key, manifest, code etc. were all right. But, in the end after wasting a lot of time, the debug keystore which I was using was the wrong one. It's was all about the SHA1 fingerprint after all.