Reputation: 1975
I'm using a MapFragment
to display a google map.
I think I have everything done right in code but map doesn't show anything
I guess it's API Key issue.
this is how I got it:
Used this command to generate SHA1 Fingerprint
:
keytool -list -v -keystore /Users/[USERNAME]/[debug.keystore path] -alias androiddebugkey -storepass android -keypass android
Created new project in Google developer console, enabled Google Maps Api V2, created new Android Key in Credentials
This is my project credentials from google developer console:
and this is Manifest
file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="erpus.distribution" android:installLocation="auto">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" />
<application android:label="ERPus.Distribution"></application>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyA14yRAzOpkXeHD86MzZbqglUlM8DxSS-I" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<permission android:name="erpus.distribution.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="erpus.distribution.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" />
<uses-permission android:name="android.permission.BROADCAST_WAP_PUSH" />
<uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:theme="@android:style/Theme.Holo.Light" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.DELETE_CACHE_FILES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
</manifest>
Any Suggestions?
Edit: I'm writing on Xamarin. Here's My fragment if anyone needs it:
public class ContractorMapFragment : Fragment {
View view;
private static int layoutId;
public override void OnActivityCreated(Bundle savedInstanceState) {
base.OnActivityCreated(savedInstanceState);
MapFragment mapFrag = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
GoogleMap Map = mapFrag.Map;
if (Map != null) {
Map.MapType = GoogleMap.MapTypeNormal;
Map.UiSettings.CompassEnabled = true;
Map.MyLocationEnabled = true;
}
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (view != null) {
ViewGroup parent = (ViewGroup)view.Parent;
if (parent != null) {
parent.RemoveView(view);
}
}
try {
if (layoutId == 0)
layoutId = Resource.Layout.MapFragmentLayout;
view = inflater.Inflate(layoutId, container, false);
}
catch (InflateException e) {
}
return view;
}
}
And View:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
class="com.google.android.gms.maps.MapFragment" />
Upvotes: 2
Views: 1043
Reputation: 3362
Xamarin is using a different debug.keystore!
keytool -exportcert -alias androiddebugkey -keystore ~/.local/share/Xamarin/Mono\ for\ Android/debug.keystore | openssl sha1 -binary | openssl base64
That should solve your problem.
Upvotes: 2