MapView does not work on emulator but google maps

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

MapView does not work on emulator but google maps

Postby HectorSavage » Fri Sep 11, 2009 1:05 pm

hello,

i try to use a mapview in my application to show a map but all i get is a grey grid something.
log cat shows this:

09-11 11:59:47.895: INFO/MapActivity(827): Handling network change notification:CONNECTED
09-11 11:59:48.005: INFO/InetAddress(827): Unknown host www.google.com, throwing UnknownHostException
.
.
.

repeating the unknown hos exception as long as the mapactivity is activ.

but using the google maps app AND internet on the emulator works just fine.

my xml file looks like that:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.                         android:id="@+id/mainlayout"
  7.  
  8.                         android:orientation="vertical"
  9.  
  10.                         android:layout_width="fill_parent"
  11.  
  12.                         android:layout_height="fill_parent" >
  13.  
  14.  
  15.  
  16.                         <com.google.android.maps.MapView
  17.  
  18.                                 android:id="@+id/mapview"
  19.  
  20.                                 android:layout_width="fill_parent"
  21.  
  22.                                 android:layout_height="fill_parent"
  23.  
  24.                                 android:clickable="true"
  25.  
  26.                                 android:apiKey="i_use_my_debug_key_here"
  27.  
  28.                         <LinearLayout
  29.  
  30.                                 android:id="@+id/zoomview"
  31.  
  32.                                 android:layout_width="wrap_content"
  33.  
  34.                                 android:layout_height="wrap_content"
  35.  
  36.                                 android:layout_alignBottom="@id/mapview"
  37.  
  38.                                 android:layout_centerHorizontal="true"
  39.  
  40.                                 />
  41.  
  42.  
  43.  
  44. </RelativeLayout>
  45.  
  46.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


and the java class:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package tab.tab;
  2.  
  3.  
  4.  
  5. import com.google.android.maps.MapActivity;
  6.  
  7. import com.google.android.maps.MapView;
  8.  
  9.  
  10.  
  11. import android.app.Activity;
  12.  
  13. import android.os.Bundle;
  14.  
  15. import android.widget.LinearLayout;
  16.  
  17. import android.widget.ZoomControls;
  18.  
  19.  
  20.  
  21.  
  22.  
  23. public class Map extends MapActivity{
  24.  
  25.         private LinearLayout linlay;
  26.  
  27.         private MapView mapView;
  28.  
  29.         private ZoomControls mZoom;
  30.  
  31.        
  32.  
  33.         @Override
  34.  
  35.         protected boolean isRouteDisplayed(){
  36.  
  37.                 return false;
  38.  
  39.         }
  40.  
  41.        
  42.  
  43.         @Override
  44.  
  45.     public void onCreate(Bundle savedInstanceState) {
  46.  
  47.         super.onCreate(savedInstanceState);
  48.  
  49.         setContentView(R.layout.maps);
  50.  
  51.         linlay = (LinearLayout) findViewById(R.id.zoomview);
  52.  
  53.         mapView = (MapView) findViewById(R.id.mapview);
  54.  
  55.         mZoom = (ZoomControls) mapView.getZoomControls();
  56.  
  57.         }
  58.  
  59. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


i use the mapview inside of a tabview, but this should not be the problem.
sdk is 1.5. i also tried out the fingerprint code which i generated with my debug key. but all staid the same.(google maps works, mapview inside my application doesn't)

any sugesstions? thanks a lot!
HectorSavage
Freshman
Freshman
 
Posts: 5
Joined: Mon Sep 07, 2009 2:08 pm

Top

Postby Bossly » Wed Sep 30, 2009 2:10 pm

You need to set permission in manifest:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <manifest ..
  2.  
  3.  
  4.  
  5.   <uses-permission android:name="android.permission.INTERNET"/>
  6.  
  7.  
  8.  
  9. </minfest>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Using android-sdk-windows-2.1
Best wishes, Bossly
User avatar
Bossly
Freshman
Freshman
 
Posts: 8
Joined: Mon Dec 01, 2008 11:03 am

Postby azraeal » Wed Sep 30, 2009 7:26 pm

MapView (and MapActivity) requires you to have a google maps API key and the package signed by the certificate the key was generated from. Your debugging key will NOT work so all you'll see is the grid.

You can get started here: http://code.google.com/android/add-ons/google-apis/
azraeal
Experienced Developer
Experienced Developer
 
Posts: 71
Joined: Fri Sep 04, 2009 6:34 pm
Location: California

Fixed

Postby Bossly » Thu Oct 01, 2009 9:17 am

Map Api key don't work if you use unsigned application which generated when you press run or debug (eclipse). First you need to sign you app and then deploy to emulator.
Using android-sdk-windows-2.1
Best wishes, Bossly
User avatar
Bossly
Freshman
Freshman
 
Posts: 8
Joined: Mon Dec 01, 2008 11:03 am

Re: Fixed

Postby Syl » Wed Nov 04, 2009 11:14 am

Bossly wrote:Map Api key don't work if you use unsigned application which generated when you press run or debug (eclipse). First you need to sign you app and then deploy to emulator.


I disagree with you.

In the Android Development guide, they say that Android system does not allow an application to be installed without being signed. So, when you press run or debug in Eclipse, first Eclipse compile the app, sign it with the debug certificate and then align it.

If it was not signed, the application couldn't be installed.

See the "Eclipse Users" section at the following URL :
http://developer.android.com/intl/fr/gu ... #debugmode
Syl
Junior Developer
Junior Developer
 
Posts: 14
Joined: Wed Oct 21, 2009 11:03 am

Top

Return to Map Problems

Who is online

Users browsing this forum: Google [Bot] and 3 guests