0

I am trying to load Google mmaps on my activity. After fighting off through a series of errors, my log cat finally shows me this error:

03-11 23:42:08.390: E/MapActivity(712): Couldn't get connection factory client

The map activity doesn't load any content. I tried searching for a solution, and:

  • My activity extends MapActivity
  • I have given the Internet persmission <uses-permission android:name="android.permission.INTERNET"/>
  • I also told the app that I will use the map library <uses-library android:name="com.google.android.maps"/>
  • My target machine and virtual machine both have API level 10 and both target Google API
  • My api key is correct and working.
  • I connect to the internet directly using broadband connection.

My guess is that I am unable to the internet. I tried to open the browser in the emulator and failed to open any URL. So I think I don't have access to internet on my emulator. After searching for a while about connecting to the internet on emulator and with reference to this question I tried running the command: C:\program files\android\android-sdk-windows\tools\emulator -avd -dns-server 8.8.8.8

But I ended up with the error:

PANIC: Could not open: C:\Documents and Settings\dwadasi\.android/avd/-dns-serv
r.ini

I couldn't understand where the problem is. I tried installing the APK file on my Android phone[2.3.6] and it worked. But I really need it to work on my emulator as there is lot of development I still need to do.

Community
  • 1
  • 1
sasidhar
  • 7,523
  • 15
  • 49
  • 75
  • any kind of firewall on the network you're connected to? port blocking at all? one of the wi-fi networks I use requires a log-in and also blocks certain ports. can't use the Android emulator on that network for anything. – dldnh Mar 11 '12 at 19:28
  • I personally disabled the firewall.... still no good... same error. :( – sasidhar Mar 11 '12 at 19:40

2 Answers2

0

I've had this happen often during development. Usually I just kill the emulator and create a new one and things fix themselves.

You've done the right thing in using the browser to test the internet connection. If you've got no connection there is no way mapping will work.

AndroidGuy
  • 3,371
  • 1
  • 19
  • 21
  • I have fiddled with my net settings and now i can connect to the internet on my emulator but still unable to load the content in my MapActivity – sasidhar Mar 12 '12 at 04:17
0

try this code.... i use this and now working.

class MapOverlay extends com.google.android.maps.Overlay
{
    @Override
    public boolean draw(Canvas canvas, MapView mapView, 
    boolean shadow, long when) 
    {
        super.draw(canvas, mapView, shadow);                   

        //---translate the GeoPoint to screen pixels---
        Point screenPts = new Point();
        mapView.getProjection().toPixels(p, screenPts);

        //---add the marker---
        Bitmap bmp = BitmapFactory.decodeResource(
            getResources(), R.drawable.pushpin2);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
        return true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event, MapView mapView) 
    {   
        add="";
        //---when user lifts his finger---
        if (event.getAction() == 1) {                
            GeoPoint p = mapView.getProjection().fromPixels(
                (int) event.getX(),
                (int) event.getY());


            Geocoder geoCoder = new Geocoder(
                    getBaseContext(), Locale.getDefault());
                try {
                    List<Address> addresses = geoCoder.getFromLocation(
                        p.getLatitudeE6()  / 1E6, 
                        p.getLongitudeE6() / 1E6, 1);

                    lattitude=p.getLatitudeE6()  / 1E6;
                    longitude=p.getLongitudeE6() / 1E6;

                    if (addresses.size() > 0) 
                    {
                        for (int i=0; i<addresses.get(0).getMaxAddressLineIndex(); 
                             i++)
                           add += addresses.get(0).getAddressLine(i) + "\n";
                    }

                    Toast.makeText(getBaseContext(), add, Toast.LENGTH_SHORT).show();


                }
                catch (IOException e) {                
                    e.printStackTrace();
                }   
                return true;

        }                
        else {
        return false;
        }
    }        
}
Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160