Reputation: 2196
Is it complusary to create Map API Key after enabling the "Google Maps Android v2" ?? Because I tried alot but I always failed to run app of Google Map. Please tell me if anyone has tried this. Thanks.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anshul"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<permission
android:name="com.anshul.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.anshul.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" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.anshul.MapActivity"
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="------removed-------" />
</application>
</manifest>
Upvotes: 0
Views: 223
Reputation: 617
This is only because of wrong SHA so use the following code to get the correct SHA of your project.
try {
PackageInfo info = getPackageManager().getPackageInfo(
"Your PAckage here",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
// // System.out.println("KEY HASH.........."+Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
System.out.println("name not found...."+e);
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException...."+e);
}
Upvotes: 0
Reputation: 3565
Yes the API Key is compulsory, otherwise Google won't authorize your app to use maps.
To get an API Key goto the Google API Console: https://code.google.com/apis/console/
Ensure "Google Maps Android API v2" is checked and then goto API Access and click "Create New Android Key...."
This allows you to enter your package name i.e "com.example.whatever" and your SHA-1 fingerprint (which can be grabbed from eclipse or using keytool). All information can be found in the above link.
Good luck
Upvotes: 1
Reputation: 7449
Yes, ofcourse its must necessary to create Google Map Api key, without it, how could you success to load the map. You must need to give that key to Android Manifest file's map api key attribute. ITS MUST NECESSARY.
Upvotes: 1