8

another day another problem, I finally managed to set up correctly google maps on my android application, or at least I thought I've done it, the whole progam starts, it even call the class which should "print" a map, but the only thing I can see is a grid with google label on it [ in the corner ]. I've checked the dalvik monitor and the error

E/MapActivity(394): Couldn't get connection factory client

occurs. I've find out on stackoverflow website that I should sent a gps signal or sth like this from dalvik monitor, and I've done it. Nothing happend, also I got the api key one more time, but nothing changed.

here is map.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This file is /res/layout/mapview.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" 
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" 
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="@+id/zoomin" 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:onClick="myClickHandler"
android:padding="12px" />
<Button android:id="@+id/zoomout" 
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="-"
android:onClick="myClickHandler" 
android:padding="12px" />
<Button android:id="@+id/sat" 
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="Satellite"
android:onClick="myClickHandler" 
android:padding="8px" />
<Button android:id="@+id/street" 
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="Street"
android:onClick="myClickHandler" 
android:padding="8px" />
<Button android:id="@+id/traffic" 
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="Traffic"
android:onClick="myClickHandler" 
android:padding="8px" />
<Button android:id="@+id/normal" 
android:layout_width="wrap_content"
android:layout_height="wrap_content" 
android:text="Normal"
android:onClick="myClickHandler" 
android:padding="8px" />
</LinearLayout>
<com.google.android.maps.MapView
android:id="@+id/mapview" 
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:clickable="true"
android:apiKey="0zPcz1VYRSpLusufJ2JoL0ffl2uxDMovgpW319w" />
</LinearLayout>

here is a MapMapa.java

public class MapMapa extends MapActivity
{
private MapView mapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView)findViewById(R.id.mapview);
}

public void myClickHandler(View target) {
switch(target.getId()) {
case R.id.zoomin:
mapView.getController().zoomIn();
break;
case R.id.zoomout:
mapView.getController().zoomOut();
break;
case R.id.sat:
mapView.setSatellite(true);
break;
case R.id.street:
mapView.setStreetView(true);
break;
case R.id.traffic:
mapView.setTraffic(true);
break;
case R.id.normal:
mapView.setSatellite(false);
mapView.setStreetView(false);
mapView.setTraffic(false);
break;
}
}
@Override
protected boolean isLocationDisplayed() {
return false;
}
@Override
protected boolean isRouteDisplayed() {
return false;
}

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="menu.dot" android:versionCode="1" ndroid:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/icon">
<uses-library android:name="com.google.android.maps" />
<activity android:name="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>
<activity android:name=".About">
android:label="@string/about_title" 
android:theme="@android:style/Theme.Dialog" >
</activity>
<activity android:name=".Exit">
andorid:label="@string/exit_title"> 
</activity>
<activity android:name=".Options">
</activity>
<activity android:name=".Start">
</activity>
<activity android:name=".Create">
</activity>
<activity android:name=".Where">
</activity>
<activity android:name=".Proceed">
</activity>
<activity android:name=".Finish">
</activity>
<activity android:name=".Login">
</activity>
<activity android:name=".OK">
</activity>
<activity android:name=".UserPanel">
</activity>
<activity android:name=".Managero">
</activity>
<activity android:name=".Edition">
</activity>
<activity android:name=".Done">
</activity>
<activity android:name=".Delete">
</activity>
<activity android:name=".MapMapa">
</activity>

</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-sdk android:minSdkVersion="3" />
</manifest> 

my view

Darshana
  • 2,462
  • 6
  • 28
  • 54
iie
  • 501
  • 4
  • 8
  • 26

5 Answers5

6
E/MapActivity(394): Couldn't get connection factory client 

This will not be issue in your case. It's just warning message.

For using Map,things you need to Keep in mind :

1.Add internet permission in Manifest file

    <uses-permission android:name="android.permission.INTERNET" />

2.Add Library code in Manifest file :

 <uses-library android:name="com.google.android.maps" /> 
  1. Extend Map Activity instead of Activity also ensure that your SDK is Google not Android

  2. Then generate Map Key using Release Key and not by using Default Android Debug key Check this post for creating Key using Release Key.

For further references check this link Mobi Forge

Output of your code

Community
  • 1
  • 1
Venky
  • 11,049
  • 5
  • 49
  • 66
1

you need to build signed apk file, try with that in your mobile. I passed same problem

lomec
  • 1,356
  • 1
  • 11
  • 10
1

In Android Map Program you have to put following permission in Android Manifest file before <application></application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.INTERNET" />

and you should write in tag and before

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

and Generate proper map api key... After that i face problem . Than I create new Android project with Google Api... I solved the problem...

Umar Mansuri
  • 127
  • 1
  • 14
0

dude, how do you get the api key ? if the debug.keystore is located in ur documents and settings, probably you will need to copy keytool.exe so you can execute keytool -list -alias androiddebugkey -keys tore debug.keystore -storepass android -keypass android -v

this will release a wrong MD5 key. you have to do the following 1- copy your debug.keystore to your program files java bin 2-go to this directory in cmd and execute the keytool command it will give you a different MD5 and this is the right one.

Bassem Wissa
  • 2,947
  • 1
  • 20
  • 20
0

You need this chk your apikey

You make you api key and when you change your eclipse you also use your keystorke..

Roadies
  • 3,309
  • 2
  • 30
  • 46