help me with my first map application

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

help me with my first map application

Postby guofengzai » Tue Apr 07, 2009 4:28 pm

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.guofengzai.android.map"
android:versionCode="1"
android:versionName="1.0.0">
<uses-library android:name="com.google.android.maps"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MapSample"
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>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>


package com.guofengzai.android.map;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

import android.app.Activity;
import android.os.Bundle;

public class MapSample extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this,"0uSfjwVveuyxYUSdEEmjZTpn51jB41o724DyrjA");
mapView.setEnabled(true);
mapView.setClickable(true);
setContentView(mapView);
}

@Override
protected boolean isRouteDisplayed() {
return false;
}
}


when i run my application, it always stops unexpected. why? thanks advance.
guofengzai
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 07, 2009 4:18 pm

Top

Postby WarrenFaith » Tue Apr 07, 2009 4:45 pm

Great post...

Here is my code, it doesn't work. thanks....


Ok lets start it easy:
Activate your LogCat and post the error.
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

the Error

Postby guofengzai » Wed Apr 08, 2009 2:54 am

whenever I run the application, the emulator shows the message below.

sorry!
the application MapSamle(process
com.guofengzai.android.map)
has stopped unexpectedly.
please try again.
Force close
guofengzai
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 07, 2009 4:18 pm

the output of the logcat

Postby guofengzai » Wed Apr 08, 2009 3:10 am

04-08 02:00:35.863: INFO/ActivityManager(50): Start proc com.guofengzai.android.map for activity com.guofengzai.android.map/.MapSample: pid=338 uid=10025 gids={3003}
04-08 02:00:36.353: WARN/dalvikvm(338): Unable to resolve superclass of Lcom/guofengzai/android/map/MapSample; (5)
04-08 02:00:36.353: WARN/dalvikvm(338): Link of class 'Lcom/guofengzai/android/map/MapSample;' failed
04-08 02:00:36.363: DEBUG/AndroidRuntime(338): Shutting down VM
04-08 02:00:36.363: WARN/dalvikvm(338): threadid=3: thread exiting with uncaught exception (group=0x4000fe68)
04-08 02:00:36.363: ERROR/AndroidRuntime(338): Uncaught handler: thread main exiting due to uncaught exception
04-08 02:00:36.383: ERROR/AndroidRuntime(338): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.guofengzai.android.map/com.guofengzai.android.map.MapSample}: java.lang.ClassNotFoundException: com.guofengzai.android.map.MapSample in loader dalvik.system.PathClassLoader@4341bdc0
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2069)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2157)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1581)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.os.Handler.dispatchMessage(Handler.java:88)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.os.Looper.loop(Looper.java:123)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.ActivityThread.main(ActivityThread.java:3739)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at java.lang.reflect.Method.invokeNative(Native Method)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at java.lang.reflect.Method.invoke(Method.java:515)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at dalvik.system.NativeStart.main(Native Method)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): Caused by: java.lang.ClassNotFoundException: com.guofengzai.android.map.MapSample in loader dalvik.system.PathClassLoader@4341bdc0
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:215)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at java.lang.ClassLoader.loadClass(ClassLoader.java:453)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at java.lang.ClassLoader.loadClass(ClassLoader.java:421)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.Instrumentation.newActivity(Instrumentation.java:1096)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
04-08 02:00:36.383: ERROR/AndroidRuntime(338): ... 11 more
04-08 02:00:36.413: INFO/Process(50): Sending signal. PID: 338 SIG: 3
04-08 02:00:36.524: INFO/dalvikvm(338): threadid=7: reacting to signal 3
04-08 02:00:36.574: INFO/dalvikvm(338): Wrote stack trace to '/data/anr/traces.txt'
04-08 02:00:36.673: INFO/jdwp(338): received file descriptor 24 from ADB
04-08 02:00:45.694: WARN/ActivityManager(50): Launch timeout has expired, giving up wake lock!
04-08 02:00:46.203: WARN/ActivityManager(50): Activity idle timeout for HistoryRecord{434e9d68 {com.guofengzai.android.map/com.guofengzai.android.map.MapSample}}
04-08 02:00:51.364: DEBUG/dalvikvm(92): GC freed 1318 objects / 69256 bytes in 157ms
04-08 02:05:36.433: INFO/Process(338): Sending signal. PID: 338 SIG: 9
04-08 02:05:36.453: INFO/ActivityManager(50): Process com.guofengzai.android.map (pid 338) has died.
guofengzai
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 07, 2009 4:18 pm

confuded about...

Postby guofengzai » Wed Apr 08, 2009 3:13 am

04-08 02:00:36.353: WARN/dalvikvm(338): Unable to resolve superclass of Lcom/guofengzai/android/map/MapSample; (5)
04-08 02:00:36.353: WARN/dalvikvm(338): Link of class 'Lcom/guofengzai/android/map/MapSample;' failed

I am new to develop with java and android, someone can explain this to me?
guofengzai
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 07, 2009 4:18 pm

Postby Ramon » Thu Apr 23, 2009 10:21 am

Hey guyz,
I think I have the same problem ...
Since my Maps Application doesn't work I created a few - lines - prototype to find out what is wrong ...
I found out that as soon as I extend my class to a MapActivity the Application wouldn't work ...
On my G1 I got the error message that the maps aplication exited abnormally ... :(

Here's my code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.MapsTest;
  3.  
  4.  
  5.  
  6. import com.google.android.maps.MapActivity;
  7.  
  8. import com.google.android.maps.MapView;
  9.  
  10.  
  11.  
  12. import android.app.Activity;
  13.  
  14. import android.os.Bundle;
  15.  
  16.  
  17.  
  18. public class MapsTest extends MapActivity {
  19.  
  20.     /** Called when the activity is first created. */
  21.  
  22.     @Override
  23.  
  24.     public void onCreate(Bundle savedInstanceState) {
  25.  
  26.         super.onCreate(savedInstanceState);
  27.  
  28.        
  29.  
  30.        
  31.  
  32.         MapView myMap = new MapView(this, "MY_KEY");
  33.  
  34.         setContentView(myMap);
  35.  
  36.     }
  37.  
  38.  
  39.  
  40.         @Override
  41.  
  42.         protected boolean isRouteDisplayed() {
  43.  
  44.                 // TODO Auto-generated method stub
  45.  
  46.                 return false;
  47.  
  48.         }
  49.  
  50.  
  51.  
  52.  
  53.  
  54. }
  55.  
  56.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


And here my Manifest.xml:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.      package="com.MapsTest"
  7.  
  8.      android:versionCode="1"
  9.  
  10.      android:versionName="1.0.0">
  11.  
  12.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  13.  
  14.         <activity android:name=".MapsTest"
  15.  
  16.                  android:label="@string/app_name">
  17.  
  18.             <intent-filter>
  19.  
  20.                 <action android:name="android.intent.action.MAIN" />
  21.  
  22.                 <category android:name="android.intent.category.LAUNCHER" />
  23.  
  24.             </intent-filter>
  25.  
  26.         </activity>
  27.  
  28.     </application>
  29.  
  30. <uses-permission android:name="android.permission.INTERNET"></uses-permission>
  31.  
  32. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
  33.  
  34. <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
  35.  
  36. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
  37.  
  38. </manifest>
  39.  
  40.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4


Can somebody help? :(
Ramon
Freshman
Freshman
 
Posts: 5
Joined: Wed Apr 22, 2009 6:41 pm

Top

Postby Ramon » Thu Apr 23, 2009 10:30 am

Hi,
I found the solution! :)

I had to add the "uses-library" line into the Manifest.xml.

Your Manifest.xml should look like this:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.      package="com.MapsTest"
  7.  
  8.      android:versionCode="1"
  9.  
  10.      android:versionName="1.0.0">
  11.  
  12.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  13.  
  14.         <activity android:name=".MapsTest"
  15.  
  16.                  android:label="@string/app_name">
  17.  
  18.             <intent-filter>
  19.  
  20.                 <action android:name="android.intent.action.MAIN" />
  21.  
  22.                 <category android:name="android.intent.category.LAUNCHER" />
  23.  
  24.             </intent-filter>
  25.  
  26.         </activity>
  27.  
  28.         <uses-library android:name="com.google.android.maps"/>
  29.  
  30.     </application>
  31.  
  32. <uses-permission android:name="android.permission.INTERNET"></uses-permission>
  33.  
  34. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
  35.  
  36. <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
  37.  
  38. <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
  39.  
  40. </manifest>
  41.  
  42.  
Parsed in 0.005 seconds, using GeSHi 1.0.8.4


Greetz!
Ramon
Ramon
Freshman
Freshman
 
Posts: 5
Joined: Wed Apr 22, 2009 6:41 pm

Postby sahil4187 » Tue May 12, 2009 2:30 pm

hi everyone....!!!
well i m also developing my simple map display application but its not running

i get the error of google.android.phone is not responding.........

and after sometime of that error emulator gets black

and i have also added all the permissions and added the library also..
still i m getting the error..

can anyone plzz help me ??
thnx in advance

Sahil
sahil4187
Freshman
Freshman
 
Posts: 8
Joined: Thu Feb 12, 2009 9:51 am

check the size of map.jar file

Postby nagkumar » Mon Jan 04, 2010 8:52 am

One other reason, we see in the latest sdk 2.0 and 2.0.1 is the maps.jar files of all the versions is 22kb.. which is wrong.. try to get the maps.jar from sdk 1.6 and sdk 1.5 and put it respective places. Not sure sure how to get map.jar of api version 5 and 6 though.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
-The Offshore Android Experts
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
- A Competant and Reliable Java/JavaME/Android Product Development Experts
nagkumar
Freshman
Freshman
 
Posts: 2
Joined: Mon Feb 09, 2009 2:53 pm
Location: Bangalore, India

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests