0

I am developing small application in android.

I already got my google maps api key.

But when i start my application in device and starts the activity that contains the google map only activity appears and zoom controls are displayed but no map displayed here is my code.

This is my layout code.

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>

This is my manifeast file code.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.project.kamani.nearby"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />


<uses-permission android:name="com.project.kamani.nearby.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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 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"/>


<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >


    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="here is used my api key but not written here"/>

    <activity
        android:name="com.project.kamani.nearby.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 already registered my application at google api console.

My java file only contains

setContentView(R.layout.activity_main);

line.

It also does not show any error can any body tell me why this is happening?

Nirav Kamani
  • 3,192
  • 7
  • 39
  • 68
  • 1
    check out this http://stackoverflow.com/questions/18609772/google-places-shows-blank/18611852#18611852...http://stackoverflow.com/questions/18636326/app-not-accepting-gmap-in-xml-file/18636637#18636637... – Aravin Sep 13 '13 at 16:17
  • post the stacktrace.... – Aravin Sep 13 '13 at 16:19
  • @Aravinth so the general solution is to regenerate the Key.am i right? – Nirav Kamani Sep 13 '13 at 16:27
  • maybe i faced the same problem and solve .. – Aravin Sep 13 '13 at 16:29
  • @Aravinth i am currently trying the solution given by you and one more thing i am unable to display logcat because when i attach my device eclipse is unable to found my device so i am unable to view logcat so i am running it by copying the apk file to my device – Nirav Kamani Sep 13 '13 at 16:36
  • refer this one it will be helpful http://wptrafficanalyzer.in/blog/showing-current-location-in-google-maps-using-api-v2-with-supportmapfragment – Aravin Sep 13 '13 at 16:40
  • @Aravinth hey bro its still not working what can be the solution?The app is unable to show map it remains blank.Worst thing ever happened is there any solution? i really need help? – Nirav Kamani Sep 13 '13 at 16:57
  • but need stacktrce. ok do you look at the above link.. – Aravin Sep 13 '13 at 16:58
  • The app was running successfully till yesterday from today it is unable to display map.How to resolve this issue? – Nirav Kamani Sep 13 '13 at 16:59
  • ok uninstall the app from device and clean your project and restart the eclipse try with new keys... – Aravin Sep 13 '13 at 17:00
  • @Aravinth i again run the key generator command in my command prompt and when i run this i found new sha1 key that is not similar to previous one can you tell me why such thing can happen? i think i deleted debug keystore once is it possible because of that it generates new sha1 key. and because of that right now i am unable to access map. – Nirav Kamani Sep 13 '13 at 17:13
  • I don't know but for me i got the same sha 1 key value for all the times..can you tell me how to generate the sha 1 key value... – Aravin Sep 13 '13 at 17:14
  • refer this one generating the sha 1 key value http://iamvijayakumar.blogspot.in/2013/02/google-maps-android-api-v2-tutorial.html – Aravin Sep 13 '13 at 17:16
  • Where is your google maps api key – Ed Holloway-George Sep 13 '13 at 17:19
  • @Aravinth i used following command "keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android" and one more thing i want to inform you now after registering new sha1 key and project and generated new android key now my application is running. THANKS GUYZ. These is a very big moment for be i cant tell you how much you helped me.Once again Thanks. – Nirav Kamani Sep 13 '13 at 17:24
  • @Aravinth can you tell me how can we do chat i am having one more problem so i can discuss with you?its related to gps? – Nirav Kamani Sep 13 '13 at 17:31
  • sorry yaar till now i did't try. Sometimes the comments will be more that 10 automatically it asks to chat... – Aravin Sep 13 '13 at 17:34
  • If you have any doubt in google maps just refer this i am also refer this one... http://wptrafficanalyzer.in/blog/gps-and-google-map-in-android-applications-series/ otherwise give your mailid... – Aravin Sep 13 '13 at 17:43
  • My app is running perfect but when i enable gps and again run the app it crashes. My task is to find the location. i found it using network provider but when i try it using gps it crashes i used getBestProvider(). when i run the app using the network provider it does not show precise location. so i also want to use GPS. – Nirav Kamani Sep 13 '13 at 17:47
  • 1
    refer this one bro.. http://wptrafficanalyzer.in/blog/showing-current-location-in-google-maps-with-gps-and-locationmanager-in-android/ – Aravin Sep 13 '13 at 17:50

2 Answers2

1

If you are deploying your application for debugging purposes (for example via USB cable) you should create SH-1 for your debug keystore otherwise you should use your own keystore (in case if you deploy application to the Google Play Market for example). For debuging purposes, create SH1 like shown below:

C:\<path-to-jdk-dir>\bin\keytool.exe -list -alias androiddebugkey -keystore "C:\users\<user-name>\.android\debug.keystore" -storepass android -keypass android

Please notice that storepass and keypass for debugging purposes is android. Then register your app with the Google APIs Console using generated SH-1 fingerprint.

Marcin S.
  • 11,161
  • 6
  • 50
  • 63
  • These answer must be checked by all the person who finds these problem because they may deleted the debug keystore then if they generate the key the sha key may be different this question remain helpful to find the solution facing the same problem. – Nirav Kamani Sep 13 '13 at 17:27
  • Glad it helped! Remember to recreate SH1 with the correct keystore when deploying an app to the Market. – Marcin S. Sep 13 '13 at 18:12
0

In your AndroidManifest, add:

    <permission
    android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

    <uses-library
    android:name="com.google.android.maps"
    android:required="true" />

Hope it helps...

Cyril Jacquart
  • 2,632
  • 3
  • 25
  • 24