2

I'm using a MapFragment to display a google map. I think I have everything done right in code but map doesn't show anythingenter image description here 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: enter image description here

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" />

arsena
  • 1,935
  • 19
  • 36

1 Answers1

2

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.

der_michael
  • 3,151
  • 1
  • 24
  • 43
  • Thanks for your response. CMD says `'openssl' is not recognized as an internal or external command`. Am I pasting the command correctly? http://i.imgur.com/untqNrW.png – arsena Dec 19 '14 at 09:09
  • For Windows users you have to install openssl for the command line (probably through cygwin. Please check this response: http://stackoverflow.com/a/7201252/1117968 – der_michael Dec 19 '14 at 16:12
  • I've installed openssl and I'm not getting any errors, but this thing doens't look like a SHA1 fingerprint http://i.imgur.com/Qp26eNh.jpg any suggestions? – arsena Dec 19 '14 at 19:22
  • That is a base64 encoded version of a binary encoded sha1 – der_michael Dec 22 '14 at 18:33
  • If you want to see just the shah run keytool -exportcert -alias androiddebugkey -keystore ~/.local/share/Xamarin/Mono\ for\ Android/debug.keystore | openssl sha1 – der_michael Dec 22 '14 at 18:33
  • Thanks again for your attention. This is what I got so far: http://i.imgur.com/lr6XA8S.png Sorry for asking too much questions but i really need to get this done. Thanks again – arsena Dec 23 '14 at 13:49
  • Insert a colon after every other character and capitalize all lower case letters maybe? – der_michael Dec 23 '14 at 18:43
  • That worked, google dev. console generated new api key. I haven't tested it yet but I think there's nothing else to ask. Thanks for your help! – arsena Dec 25 '14 at 07:43