Alright, here is what I did using the example
Generated the key by the command
$ keytool -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android
Copy pasted the SHA1 sum in the Google API Console + my packagename:
sum;com.my.package
Enabled Google Map API v2 in the same project in Google API Console
Copied it to the Manifest application in meta-data.
Downloaded via SDK manager and Imported the google-play-services_lib project and referenced it as the library project. As well as the ActionBarSherlock.
Before launching I make sure the GooglePlayServices are available.
Manifest:
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.my.package.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.my.package.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Application:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="debug_key"/>
The proguard stuff are added too, but I don't obfuscate right now.
DrugstoresMapActivity extends SherlockFragmentActivity
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map_fragment"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
project.properties
target=android-17
android.library.reference.1=../google-play-services_lib
android.library.reference.2=../ActionBarSherlock
The ActionBarSherlock has android-support-v4 in libs, not the main project if that matters.
The StartupActivity makes sure that DrugstoresMapActivity will be launched only if the services available
private void attempt() {
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
switch (result) {
case ConnectionResult.SUCCESS:
startActivity(new Intent(this, DrugstoresMapActivity.class));
finish();
break;
default:
GooglePlayServicesUtil.getErrorDialog(result, this, REQUEST_DIALOG)
.show();
break;
}
}
Double-checked the keys are fine. No clue what I missed here.
You won't be charged until your usage exceeds $200 in a month. Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).
If you have a Google Map on your website, you are using Google Maps API to load that map. Google recently updated their terms and use of their maps API which is effective starting on July 16, 2018. A valid API key and a Google Cloud Platform billing account are now required.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With