Accessing Your Test Web Site form Your Physical Android Test Device
Hello again
Well I’m just finishing reading an advance copy of HTML5 in Action and I’ve been testing things out via a variety of web browsers.
Then I thought let’s use the Android device besides me. It’s attached to the network so the browser can see the local test web sites.
Right no problems it’s on a hostname that maps to the HTML5 CNAME in my DNS. So I fire up the Android browser and type in:
Web site not found is the only response.
Much messing about with host files most important of which was discovering that the following works:
adb shell ping <ip-address | hostname>
So I try
C:\DEV>adb shell ping html5
ping: unknown host html5
Then I try
C:\DEV>adb shell ping html5.xxx.int
PING websitedev.xxx.int (192.168.1.150) 56(84) bytes of data.
64 bytes from 192.168.1.150: icmp_seq=1 ttl=128 time=22.5 ms
64 bytes from 192.168.1.150: icmp_seq=2 ttl=128 time=11.0 ms
So the lesson learned is that the host resolver will not pick up the default domain name, and why should it it’s not like its a Windows device.
Back to the browser and
Works perfectly.
Cheers
Sebastian
Google Maps not working in Custom Application
Hello There
I had just finished the first version of Transports of Delight.
All it does is display a map.
It works beautifully on the emulator and Gina’s Samsung Galaxy IIIs but on my cheap and cheerful M009S Android 4.0 Android Tablet it just gave an error of:
Transports of Delight has terminated.
I started to debug it.
- Attach the tablet to the PC via USB.
- View the LOGCAT via the following command.
adb -s <serial number> shell logcat
- Run the application on the tablet.
- View the output on the PC.
In my case the key line is…
exception: java.lang.NoClassDefFoundError: android.security.MessageDigest
Some googling and head scratching.
https://productforums.google.com/forum/#!msg/maps/KinrGn9DcIE/OCsz2G3BgSMJ
Right so it is an out of date library on the device. Specifically com.google.android.maps.jar.
I downloaded the correct library and, after saving the old one, loaded it onto the device.
That’s a bingo!
It works but we aren’t finished.
As well as “Deploy Early, Deploy Often” another saying Marcus and I came up with is “Everything is data”.
In this case the correct library solves a problem that our application has so it belongs in the project.
- Create an ‘external’ folder in the project.
- Add a ReadMe.txt explaining what the folder is for, in this case to hold files external to the project but possiblyneeded.
- Copy the correct com.google.android.maps.jar into the folder.
- Put a quick write up into the ReadMe.txt.
- Version it into Source Control.
Simple but it holds what we need and with only a single file the ReadMe.txt is enough, we’ll do something more sophisticated when we need to.
Huzzah!
Sebastian
How to reboot your Android device
Hello
This should be easy really and it is.
- From your development machine connect via a USB cable.
- Run the following command:
adb -s <serialnumber> reboot
So for my cheap and cheerful tablet it is:
adb -s 20080411 reboot
Cheers
Sebastian
Developers only tend to see what helps them do development
A quote from Gina Holden who has dealt with developers for longer than anyone should really have to.
It came up in discussion about what is agile programming, or rather what is Agile?
I pointed her to the original Agile Manifesto and her comment was:
Sounds great and practical apart from “Customer collaboration over contract negotiation” – that’s just stupid and naive.
We then had a little discussion about the difference between ‘over’ and ‘instead of’ and I pointed out that most developers treat the right hand side (or RHS as we techies like to call it) as BAD whilst the left hand side (or LHS) as GOOD and that this was not the point. The aim is really LHS GOOD, RHS GREAT.
This then gave rise to the fantastic quote from Gina:
Developers only tend to see what helps them do development – not what the rest of the project is doing……
And this gave me pause.
I think of Agile as a thing in itself but really it’s just part of the development chain, scrub that, it’s part of the delivery chain, scrub that it’s a way of looking at the whole project.
Yes the whole project. Not just definition, not just development, not just deployment. It’s a way of looking at the entire lifecycle from cradle to grave, of an idea. It could all be agile from having the idea to delivering the first version to sun setting the final version.
With this in mind and bearing in mind we have just started on an idea
Help people get places via public transport
maybe we should be doing it.
More to follow.
Cheers
Sebastian
Connect Your Android Device to Your PC to allow ADB Access
Hello There
So you have written your first, trivial, Android app and you want to test it on a real device.
Not a problem the ADB (Android Debug Bridge) will let you do just that.
- On your Android device.
- Check USB debugging is ON.
- Plug you Android Device into your PC via a USB cable.
- On your PC.
- Start up a command session.
- Run “adb devices” this will list all your devices:
List of devices attached
emulator-5554 device
20080411 device - Install your package:
adb -s 20080411 install Transports.apk - Remove your package:
adb -s 20080411 uninstall uk.co.simpleinnovation.transports
However you may find that the device does not show up. This is caused by a lack of suitable drivers.
The easiest way I’ve found to resolve this is to install PdaNet for Android on your PC, choosing Other as your phone type.
Now all I need to do is solve the following issue:
C:\Users\Sebastian.BS\.android>adb -s 20080411 install Transports.apk
2418 KB/s (153569 bytes in 0.062s)
pkg: /data/local/tmp/Transports.apk
pkg—-5——:
pkg—-6——:
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
Cheers
Sebastian
Google Map View gives ClassNotFoundException
Good morning
I just added a MapActivity to our Transports of Delight Android application and now when I try and start the application on the emulator I get the following in the logs:
07-17 21:25:58.004: E/AndroidRuntime(665): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{uk.co.simpleinnovation.transports/uk.co.simpleinnovation.transports.MapViewActivity}: java.lang.ClassNotFoundException: uk.co.simpleinnovation.transports.MapViewActivity
After much headscratching it turned out to be NOT explicitly allowing the application to use the Google Maps library as follows:
<uses-library android:name=”com.google.android.maps” />
This resolves the problem nicely.
Cheers
Sebastian
Getting a Development Key for Google Maps for Android
Things fall apart.
Or maybe Fear Change?
Trying to get an API key to use Google Maps and it doesn’t quite work as things have changed in…
Java!
Yes as of JDK 1.7 keytool produces an SHA1 key and not an MDA5 key by default and you need the MDA5 key.
How to sort out? Easy enough just use a -v option on the keytool command.
keytool -list -v -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android
Then pick out the MDA5 key and off to: https://developers.google.com/android/maps-api-signup as you would expect.
Cheers
Sebastian
Setting up an Android Development Environment
And so I needed yet another android development environment.
Why?
See this post.
So I used the latest guide on the Developer Tools Web Site at http://developer.android.com/sdk/installing/index.html.
Note that there is an issue though. When you try to install the Android Developer Tools you get:
Cannot complete the install because one or more required items could not be found. Software being installed: Android Development Tools 20.0.0.v201206242043-391819 (com.android.ide.eclipse.adt.feature.group 20.0.0.v201206242043-391819)
To solve this you need to add some sites to the “Available Software Sites”.
Juno http://download.eclipse.org/releases/juno The Eclipse Project Updates http://download.eclipse.org/eclipse/updates/4.2
Also after the installation you get the configuration screen automatically.
Then all you need to do is install subclipse.
http://subclipse.tigris.org/servlets/ProjectProcess
Or just add http://subclipse.tigris.org/update_1.8.x as a new software location.
Cheers
Sebastian
Deploying Development Releases to Real Android Real Devices
The very first version of Transports of Delight, a useful travel companion Android App, is ready to be deployed to our real Android devices for testing.
This is a very minimal featured release being used prototype our development, test and deploy processes.
So how did it go?
Not well at all.
Why?
Well it turns out Microsofts Hyper-V engine does not support USB devices. This means the ADB (Android Development Bridge) cannot access the test machine to install the software.
So what are my options?
- Copy the .adk files via:
- Copy from development machine workspace\<Project>\bin to a physical machine transfer share.
- Copy from the transfer share to a USB drive.
- Attach the USB drive to the target Android device.
- Copy from the USB drive /mnt/usbhost1 to the relevant area, e.g. a backup area.
- Restore the apk backup
- Install the development environment on a physical machine.
So option 2 it is.
This is when the mantra Marcus and I have been chanting in SCRUM meetings for years now shows it’s true worth.
“Deploy Early, Deploy Often”.
Cheers
Sebastian
How to create an Android VM using Hyper-V
Hello, World
As we start to develop Android Apps we are determined to do it properly, that is to maintain a high quality.
One of the things that helps with quality is testing and with testing one of the things that helps is to be easily able to get back to a known position.
Virtual machines are a real boon to this so I have created and snapshotted an Android 4.0 (Ice Cream Sandwich) machine in Hyper-V.
How to do it is beautifully explained in the following blog:
http://blogs.blackmarble.co.uk/blogs/rhepworth/category/hyper-v.aspx
Cheers
Sebastian