Android ViewMap example – a beginner’s very basic observations
April 9, 2011 at 2:29 pm Leave a comment
Hi,
I’m just got an eclipse project containing code coming from http://developer.android.com/guide/tutorials/views/hello-mapview.html but with slight changes. I wanted to run it here to help with debugging some problems. As I had never written an android project I had some very basic “insights”.
- I had to generate my own MapKey. I got the information for that from: http://code.google.com/intl/de-DE/android/add-ons/google-apis/mapkey.html . For now I only got a MapKey for my debug.keystore . You need keytool for it and it’s part of the Oracle SDK within the bin folder
- Sometimes I might have executed the main.xml that produced an main.out.xml. I had to delete that, when it was there.
- I wanted to have a look at the main.xml. It was not perfectly formatted. As I wasn’t sure whether it was correct on an XML-level I ran Source/Format on it. Then I was able to see that it was actually correct.
- I had an error symbol on my project and I could run it. There were, however, no errors indicated in the log. So I ran Project/Clean and it got rid of the problem. (From: http://stackoverflow.com/questions/3638660/undefined-error-when-trying-to-run-android-tutorial-form-stuff )
- Then I had the error log: No command output when running: ‘am start -n google.map/google.map.HelloViewMap -a android.intent.action.MAIN -c android.intent.category.LAUNCHER’ on device emulator” specifically
eclipse.buildId=M20100909-0800java.version=1.6.0_24java.vendor=Sun Microsystems Inc.BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DEFramework arguments: -product org.eclipse.epp.package.jee.productCommand-line arguments: -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product
ErrorSat Apr 09 15:56:54 CEST 2011No command output when running: 'am start -n google.map/google.map.HelloViewMap -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' on device emulator-5554
com.android.ddmlib.ShellCommandUnresponsiveException at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:408) at com.android.ddmlib.Device.executeShellCommand(Device.java:276) at com.android.ide.eclipse.adt.internal.launch.ActivityLaunchAction.doLaunchAction(Unknown Source) at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.launchApp(Unknown Source) at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.clientChanged(Unknown Source) at com.android.ddmlib.AndroidDebugBridge.clientChanged(AndroidDebugBridge.java:867) at com.android.ddmlib.Device.update(Device.java:398) at com.android.ddmlib.Client.update(Client.java:834) at com.android.ddmlib.HandleAppName.handleAPNM(HandleAppName.java:90) at com.android.ddmlib.HandleAppName.handleChunk(HandleAppName.java:64) at com.android.ddmlib.MonitorThread.callHandler(MonitorThread.java:414) at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:322) at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
. http://www.anddev.org/sdk-adt-emulator-problems-f16/unparsed-aapt-errors-check-the-console-for-output-t12615.html told me to just delete it or clean the project.
- I started the Android app but I wasn’t sure whether it was still running when I hit the “Home” button to go back to the main menu. I found the taskmanager at “All Programs/DevTools/Running Processes”. it seems, it was not running after I went back to the main menu.
- I tried to do some logging with System.out.println but http://developer.android.com/resources/faq/commontasks.html#logginghttp://groups.google.com/group/android-developers/browse_thread/thread/a4896b24bd355a30/208a143b4eec58c0?lnk=gst&q=System.out.println&pli=1 and http://developer.android.com/reference/android/util/Log.html tell me to use Log.v(“myAppTag”, “step 5 is about to happen”) instead. You can read the output with starting ddms.bat from “android-sdk-windows/tools”. But System.out.println is also listed within Dalvik Debug Monitor. You will have to click on the emulator in the upper left windows to see the outputs.
- I came across the bug: http://code.google.com/p/android/issues/detail?id=8816 that Geocoder.getFromLocationName throws an java.io.IOException: Service not Available. This seems to be a bug in the 2.2 emulator. In the bug link there is comment #21 with a workaround. I downgraded to 2.1 (my device is 2.1 anyhow). However then in main.xml I had to replace all “match_parent” by “fill_parent”. Tihs page http://stackoverflow.com/questions/4936553/android-how-can-you-align-a-button-at-the-bottom-and-listview-above says that match_parent was fill_parent till 2.1.
- You can set the information the android emulator sends to the android operating systems. http://www.helloandroid.com/tutorials/how-set-location-emulator tells you, you can do it in ddms.bat (Dalvik Debug Monitor) in the tab “Emulator Control” under Location Controls.
- One should maybe put the geocoder information request in a separate thread as it needs an internet connection that might be slow. http://stackoverflow.com/questions/472313/android-reverse-geocoding-getfromlocation
- I got this error message ERROR/AndroidRuntime(331): Uncaught handler: thread main exiting due to uncaught exception 06-14 22:13:34.031: ERROR/AndroidRuntime(331): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.HelloMap}: when I tried to add a map to an Activity. As pointed out here: http://stackoverflow.com/questions/3040307/android-hellomap-example-giving-exception I had to extend my Activity from MapActivity. In order for that to be possible I had to change the Android I compile against from 1.5 to “Google API + Android 1.5″. For that to work I had to let Eclipse add the required “isRouteDisplayed()” method.
- Then I got the error java.lang.NoClassDefFoundError: … and then the name of the class I had just changed from extending not Activity but MapActivity. I forgot adding ’<uses-library android:name=”com.google.android.maps” />’ in the manifest.xml.
- I’m now using a “clickable = true” map within a scrollable Activity. Now only the horizontal touch-movements are represented in the map. When I flick up and down this is only reflected in moving the whole activity up and down but not the map. Is there a UI trick for the user to use the map completely?
I’ll publish this now and might come back later
Entry filed under: Uncategorized. Tags: .
Trackback this post | Subscribe to the comments via RSS Feed