Select a device with min API level <x>

April 5, 2013, 4:00 am

Had a frustrating hour or so today trying to get Eclipse to run goCatch on an old HTC Desire running Android 2.2. Eventually found the solution so this is a note to self to avoid this in the future.

The problem was that old device was not showing up in the Android Device Chooser, who (notice how I anthropomorphize pretty much everything?) smugly asserted Select a device with min API level 11. This sent me into a little bit of tailspin because I had jumped feet first into moving over to Android Maps V2, ActionBarSherlock and Support Library goodness with the understanding that I could support devices all the way back to 2.2. I frantically went through all the dependencies I had recently introduced, looking for a minSdkVersion greater than 8 (Android 2.2). To my relief I didn't find any. I double checked my own manifest and made sure my minimum API was set correctly. It was:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>

What the hell?! Why is the device chooser insisting I could only run on devices with API level of 11 or more? I dug through about a thousand (might have been less than a thousand) config screens in Eclipse looking for a obscure project property that was causing the issue, with no luck.

Eventually I decided I would reduce the targetSdkVersion down to 8 and see if I could build and run on the old device. I updated the manifest and did a clean build for good measure. Eclipse built my project and ran it on the device. Android Device Chooser was now happily insisting that I should Select a device with min API level 8.

Not really wanting to target API 8, I udpated the Android Manifest back to its original state and voila everything works. Hooray!

Permalink - Comments - Tags: Development,Android,Google

You might have forgotten to update your Android Maps V2 API key

April 5, 2013, 3:31 am

If you notice your logcat rapidly filling up with Failed to load map. Could not contact Google servers, you might have forgotten to update your Android Maps V2 key in AndroidManifest.xml.

<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="your_maps_key"/>

The maps object gets quite angry, but remains sadly inarticulate when this happens. Just sayin.

E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers. E/Google Maps Android API( 2277): Failed to load map. Could not contact Google servers.

Permalink - Comments - Tags: Development,Android,Google

How I got more pages from my sitemap into the Google index

November 3, 2011, 10:11 pm

N.B. Disclaimer: For SEO types this might all seem very obvious, but I thought someone might find it interesting.

Wow! In July this year I tweeted that I was working on improving the number of URLs I had in the index:

Working on getting more urls in my sitemap into the index. Currently at 308 of 1804 links. Hoping todays changes will improve that ratio.

Just checked my Webmaster tools and discovered of the 1885 pages on my site today, 1790 are in the index. So what did I do?

You have to be careful with Monetization

I have an Amazon affiliate account and when I was building my World War Two timeline project it seemed like a good idea, in addition to linking to Wikipedia articles, to link to Amazon search results for the title of each data point (using my affiliate link of course).

For something like my entry on D-Day, this kinda worked. You got a link that looked something like this:

Buy a book about 'D-Day'

This makes sense right? I have to monetize this thing somehow and maybe people want to buy a book about this topic they have clicked on? It turns out very few people actually did that and in the end it was just adding a distracting link to my content.

The cartoon caricature of the Googlebot in my head saw those pages of affiliate links and frowned, so I removed them (This is the reason that in my head the Googlebot is an enthusiastic labrador puppy).

Since then I have built iPhone and Android apps to provide new ways of getting to my content and found that is a much more effective way of monetizing my work.

Spammy user profiles

Every now and then a medical supplies peddler or enthusiastic pornographer will find their way to my user signup page. Their profile descriptions are often entertaining, but perhaps something of a red flag for the G-rated Googlebot. To prevent their potentially nasty content from affecting my page rank, I use robots.txt to hide those pages until I have time to nuke them.

Disallow: /user.php

Titles, Titles, Titles

Thanks to the HTML suggestions section in the Webmaster tools I noticed that I had lots of duplicate titles for my content. Each historical data point page was using the generic "World War Two Timeline Project" title instead of a title that summarised the information on the page. It was a very simple change to update these pages to render a more appropriate title and suddenly the number of duplicates for my site dropped dramatically.

Static pages for map popups

This one is actually still a work in progress.

I have lots (1128) of Info Windows on my Patrick O'Brian Mapping Project containing content that should be searchable by Google but currently aren't.

My first attempt at solving this problem was to create a whole pile of static pages that were chained together (with next and previous links) in a giant linked list. I think the Googlebot started down my list of pages and decided it was getting mired in some pathological labyrinth and maybe it would come back another day.

I think that this is something that the Googlebot could probably figure out on its own (indexing the data from the Javascript map), so I am hoping that by the time I get around to revisting the issue, they will have worked it out. I am looking at you Chris Broadfoot ;)

Conclusions

So pretty simple and hopefully intuitive changes and it looks like they worked. I found a good way of getting into the mindset for this type of thing is to watch some of Matt Cutts' Webmaster Q&A videos. I found his even tempered, sensible explanations for the various things that Google does to improve search were enough to get me thinking about this stuff the right way.

Permalink - Comments - Tags: Development,Google

Introduction to MapView on Android - Codelab

August 25, 2011, 2:54 am

I am giving a talk about Android Google Maps development at the Android Australia User Group - Sydney meetup tonight. I hope you can make it.

I have put together a very simple code lab going over the basics for adding maps to your Android apps.

  • Before - A simple list based app that loads a 'Detail' activity.
  • After - Even list entries will load a native MapView based activity, odd list entries will use the Javascript Google Maps API in a WebView. Native views also geocode the name provided to set the map center.

This stuff is very much an introduction and much of it is covered in the Google Map View tutorial, but hopefully some people will find it useful.

Update

In my rush to get something together for the code lab I left some rather embarrassing, unsafe threading code in my "After" code lab.

I was calling set location on my MapView from my worker thread. Oops. Thanks to Darren Mason for pointing out this rather glaring error.

Make sure that you access the Android UI toolkit only on the UI thread.

I have updated the sample to use an AsynchTask to safely update my MapView when the blocking call finishes in the worker thread.

private class GeocodeTask extends AsyncTask { protected GeoPoint doInBackground(String... name) { return blockingGeocodeCall (name[0]); } protected void onPostExecute(GeoPoint result) { setLocation(result); } }

Permalink - Comments - Tags: Development,Android,Google

When your running emulator isn't showing up in the Android Device Chooser

July 18, 2011, 8:06 am

This has been documented elsewhere for similar cases and is more of a note to self than anything else.

Occasionally I have found, while debugging, Eclipse will lose track of the running Android emulator instance. So the emulator is happily chugging away, but will refuse to appear in the 'Android Device Chooser' running device list. Because the emulator takes so long to start, I am loath to kill and restart it, which usually fixes the problem.

With a little bit of Googling I stumbled across someone with a similar issue, who was advised to try the following commands to resolve the problem:

adb kill-server adb start-server

The Android Debug Bridge documentation talks about the occasional necessity to restart the server when it is 'unresponsive', so this is clearly one of those cases:

In some cases, you might need to terminate the adb server process and then restart it. For example, if adb does not respond to a command, you can terminate the server and restart it and that may resolve the problem.

Permalink - Comments - Tags: Development,Android,Google