1

I want to display Google Map APIv2 in an emulator. It seems to me that I've done everything according to official Google tutorial and this tutorial. I see "+" and "-" buttons to adjust zoom, but don't see the map. I've tried to regenerate keystore and provide another api key, but this had no effect. The only guess I have is that eclipse signs my application with a debug key, though I've done export procedure from my keystore.

Or may be it's somehow jdk issue? I have jdk 1.7 installed, and android uses 1.6

Here are the errors that I get:

E/Trace(681): error opening trace file: No such file or directory (2)
E/ActivityThread(681): Failed to find provider info for com.google.settings
E/ActivityThread(681): Failed to find provider info for com.google.settings
E/ActivityThread(681): Failed to find provider info for com.google.android.gsf.gservices
E/ActivityThread(681): Failed to find provider info for com.google.android.gsf.gservices

AndroidManifest.xml

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

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

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

    <permission
          android:name="us.irz.findme.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
    <uses-permission android:name="us.irz.findme.permission.MAPS_RECEIVE"/>

        <uses-permission android:name="android.permission.INTERNET"/>        
        <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

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

        <activity
            android:name="us.irz.findme.LoginActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="us.irz.findme.DeviceActivity"></activity>
        <activity android:name="us.irz.findme.MapActivity"></activity>
        <activity android:name="us.irz.findme.TabsActivity"></activity>
            <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="my_api_key"/>
    </application>
</manifest>

map.xml file

<?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"
class="com.google.android.gms.maps.SupportMapFragment"/> 

MainActivity.java

public class MainActivity extends FragmentActivity implements OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);
}

...
}
Natalia
  • 783
  • 7
  • 18
  • @StéphaneBruckert Yes, stupid mistake: I pasted key for Google Map API v2, instead of Google Map Android API v2 – Natalia Mar 14 '13 at 08:22

2 Answers2

1

If you like to try it in a emulator, the emulator has to be created as with target Google Api level xx, not with Android 2.3 (for example), Sometimes the emulator can't load the map, so I recomended you to use a real Android device, your phone, tablet or something like this... Too check that the api key is the correct.. If you know spanish, can follow this tuto, is very good http://www.sgoliver.net/blog/?page_id=3011, search the section "Mapas en Android (Google Maps Android API v2) – I"...

Leonardo Sapuy
  • 2,600
  • 2
  • 23
  • 30
  • I temporary have no internet connection on android device. Somehow it seems to be a key issue, because when I replace key with random string errors remain the same. I don't know spanish and have no idea what is wrong about the key... – Natalia Jan 31 '13 at 13:39
  • how are you getting the api key?? – Leonardo Sapuy Jan 31 '13 at 20:26
  • I generate keystore and key (tried both with eclipse and keytool itself), than put SHA-1 of it in Google Console, get my key and put it into manifest. Then in eclipse I do "Export Android Application", specify my keystore and key there, and Eclipse generates .apk file. Then I've tried to use "Run as Android application" and tried to install generated .apk by adt - both had effect from above. – Natalia Feb 01 '13 at 06:58
  • Follow these steps to a correcte key generate: -First you have to get the "Google Play services" -> Android SDK Manager in Eclipse, you can find it into the appart "Extras" -Next you have to go here https://code.google.com/apis/console/ and create a new Project: (watch the img) http://www.sgoliver.net/blog/wp-content/uploads/2012/12/create-api-project-2.png, next enter the name, and next enable the "Google Maps Android API v2" -Then, go in the left panel to API Access and press "Create new android key", here you have to insert the SHA1. – Leonardo Sapuy Feb 01 '13 at 13:28
  • Open a cmd, and go to you keystore path (can be you keystore or the debug keystore) and execute this command: C:\Users\leonrdo\.android> "C:\Program Files\Java\jdk1.7.0_07\bin\keytool.exe" -list -v -keystore your.keystore -alias youraliaskeystore -storepass passkeytore -keypass passalias if u do it fine, will appear some codes (check the img) http://www.sgoliver.net/blog/wp-content/uploads/2012/12/sha1.png copy the SHA1 and paste it into the google api's window with u package name, example: 45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;com.example and u have your api key.. – Leonardo Sapuy Feb 01 '13 at 13:34
  • Remember that u have to import the Google Play services into the workspace and next add the library to your project.. Your manifest it's ok, it will be worKs correctly – Leonardo Sapuy Feb 01 '13 at 13:37
0

Please check that you added the Google Play Services library in you project.

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
  • in properties-android reference to google-play-services_lib is checked – Natalia Jan 31 '13 at 12:41
  • Have you defined the map key as in your manifest i don't find the map key. or you have not just shown here but you have actually defined it ? – GrIsHu Jan 31 '13 at 13:25
  • I defined it but replaced with "my_api_key". Somehow it seems to be key issue, because when I change it for random string - errors still the same. – Natalia Jan 31 '13 at 13:35