Tuesday, December 21, 2010

Android Nexus 1 Flashing - assert failed: write_raw_image("/tmp/boot.img", "boot") - solved

NOTE: I've since noticed that WiFi doesn't work with the method outlined below, however it does work with "fastboot boot boot.img" so further investigation is required. Some other users are saying that reflashing the hboot helps, but there are drawbacks to that as well.... Still if you are having this error and want to try gingerbread asap then the solution below is good:

It is a fun error isn't it, thousands of Nexus 1 users are happily flashing the latest ROMs onto their devices with no issues and when you try it you get something a little like this:

Installing update...
assert failed: write_raw_image("/tmp/boot.img", "boot")
E:Error in /sdcard/update.zip
(Status 7)
Installation aborted.

Same here, however there is light at the end of the tunnel. The problem is a lack of space to flash the new boot image, the cause could be one of two things:

1) You have some corrupted memory in the boot space, shrinking the size of the available boot partition and not allowing larger boot images to reside there.
2) This is a guess and I'd be interested in feedback: The Nexus 1 I use for custom ROMs is from the very very first Google seeding back in late 2009. I wonder if these devices had slightly smaller boot partitions.

Either way, there is a solution! The boot partition and the recovery partition are physically very similar, so after flashing the latest Gingerbread ROM (Gingerbread-Rooted-Gapps-v.06-signed.zip in this case, from the awesome XDA forums), I do this:

1) Extract boot.img from the ROMs zip file
2) Connect my N1 to my PC via USB
3) Boot the N1 into Fastboot by holding down the trackball when turning it on.
4) Flash the boot.img into the recovery partition:
"fastboot flash recovery boot.img" (fastboot is in the platform-tools directory of the SDK these days)

Now when I boot my Nexus 1 I hold down the trackball to get to Fastboot and then choose recovery mode, et voila Gingerbread launches.

If you need to get back to a real recovery mode you can either boot into Fastboot then boot a recovery image from your PC e.g. "fastboot boot recovery-RA-nexus-v2.0.0-CM.img"
Or reflash a recovery image, do your thing and then reflash the boot image.

I found this trick out at XDA Forums (where else?), here http://forum.xda-developers.com/showthread.php?t=731657

Wednesday, December 01, 2010

1 day into a relationship with the SonyEricsson LiveView

I absolutely love its geekiness. I'm running it with a stock Nexus 1 on 2.2.1. Yes It does disconnect all the time and I spend quite a lot of time turning it off and on again, re-pairing the bluetooth and generally willing it into life. But, I'll definitely knock a couple of apps up for it in the hope that SonyEricsson make a second generation device with a higher res screen, full touch support and a longer battery life. Some say the battery life is pathetic, but that is an understatement, a watch that doesn't get through half a day is crazy.

So far the best use for it is remote controlling the music players, i've had no problem with the built in Music remote control and my Nexus 1. It supports play/pause, volume control, next/previous track. The Where Am I plugin is ok, brings up a map of your current location on the LiveView. The GMail and SMS plugins don't seem particularly reliable, but I'll keep persisting.

Tuesday, August 24, 2010

Providing your Android Activity with a Theme

I've recently been asked a couple of times by new Android developers how 'Tech Buzz Widget' manages to overlay itself ontop of the desktop, allowing your wallpaper to show through. Assuming that it is easier to Google the answer than ask me, it may be somethiing that there isn't enough detail on already. So here is my 10 cents.

The main detail is to set the correct android:theme for your activity in the AndroidManifest.xml. For Tech Buzz Widget we used android:theme="@android:style/Theme.Translucent.NoTitleBar"

So the activity looked like this:

<activity android:name=".FullArticleView" class=".FullArticleView"
<action android:name="android.intent.action.MAIN" />

Once you've done that you you'll see that any elements of your layout that are transparent or unfilled will show through onto the underlying application or desktop. To make this more obvious in Tech Buzz we put a margin around the entire layout.

The exact details of all the activity themes available in the current Android platform are available in the Android source here: http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/res/res/values/themes.xml

Search for Theme.Translucent and you'll get the idea. There are fullscreen themes as well if you want to get rid of the notification bar. You can also define your own themes in a similar way.

Tuesday, June 15, 2010

1 Million Installs of Battery Widget for Android!!

As far as milestones go I'm thinking that this is a pretty big one. I've just returned from a trip to the Le Mans 24 hour race to find out that the first Android app that I submitted to the Market has shot through 1m installs. Fingers crossed that this is the one that gets you an E-mail from Mr Rubin ;)

Battery Widget is currently ranked 24th 'top free' application in the Productivity category in the UK and has been in the top 30 for over a year with a top 5 spot for a while. I'm thinking it may be time to revisit the app and sharpen it up for the higher res screens of today's Android devices and allow a few different colour combinations.

Although I'm super happy that Battery Widget is staying up the Android charts it is a double edged sword. As an Android fan-boi super-user fanatic there is definitely still an issue with freshness and churn in the top spots of the Free/Paid Android apps/games in the Market. The Market algorithm that is keeping Battery Widget up near the top for over a year is also making it hard for new apps to break through and for me as a user to find those exciting new applications. I'd 100% definitely sacrifice the popularity of this app for a more harsh ranking of older applications. I wonder what it would take now for a new application to enter the store and knock Battery Widget down a spot or two? It is still getting more new installs a day than all of my other apps combined.

You may say that the Market is favouring new Android users and making it easier for them to setup their devices with top apps, but there should be a better way for long time users of discovering new awesomeness without trawling through hundreds of pages of 'Just In' apps. The awesome apps are out there and I usually find multiple new great apps or games each time I have 15+ minutes to spare to 'trawl'. No doubt Google are fully aware of this and it'll just be a matter of time.

Thanks to all who have downloaded! Here's to the next Million.

Monday, April 12, 2010

Creating an Android Activity with no UI

Since I released 'Dimmer (Night Mode)' into the Android Market I've had a few Android devs asking how to create Activity based applications with no UI.
The answer is that you need to set the activity theme in the manifest, for dimmer I use:


like this in AndroidManifest.xml:

<activity android:name=".Dimmer"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

The latest set of activity themes are defined in /res/values/themes.xml in the Android source here.

Which may not be particularly user friendly but it also demonstrates how you can create your own activity themes in your own /res/values/themes.xml if you so desire.

Note I'm not using the theme 'NoDisplay' as I do actually show notifications on the screen as the Activity is going about its business.

Sunday, February 21, 2010

Getting Started with a Nexus 1 - Apps, Hints & Tips

Quite a few of my friends, especially in the mobile industry, have aquired Nexus One's recently and more often than not it is their first foray into the world of Android.

Over the last couple of days I've been asked to help set several of them up with my preferred settings, applications, games, etc... So I'll maintain this post and from now on I can point people here.

First Boot
First and most importantly is that if you have multiple G-Mail and Google Apps accounts, make sure you sign in with your 'primary' one first. The N1 may have multiple GMail account support but it will only sync one calendar, the first one you enter. Also the first sync is going to use a whole bunch of data, so best to be on wifi.

If you received your Nexus 1 at MWC 2010 it will now inform you that a firmware update is ready. This update adds multi-touch support to the Browser, Gallery and Google Maps, go for it, it doesn't take long.

Android Usage Hints
Notification Bar - Top of the screen where the clock and battery level resides. New notifications from the apps on your phone will appear here. To see the detail of the notifications just drag the bar down.

Menu Button - On the N1 it is the second button in, above the trackball, with the 4 lines on it. Most apps have a Menu and this button makes it appear. Holding the button for a second also forces the On Screen Keyboard to appear, which can be a useful override at times.

Home Button - A bit like the button on the iPhone, always gets you back to your home screen. Hold it down to view the last 6 apps that you've run. These aren't necessarily still running.

Long Press - One of the interaction metaphors in Android, especially on items shown in a list. It is akin to the right click in Windows. Just touch and hold an item for a couple of seconds and sometimes a context sensitive menu will appear.

Stars - Look for small stars in the top right of UI's. They appear in G-Mail (you should know about them there for 'starring' mails), but they also appear on Google Maps for saving favourties if you long press on a location and touch the address bubble. Another place is in contacts, you can star a contact and then add a live-folder called 'Starred Contacts' to your home screen, keeping the most contacted people easy to access.

Widgets - Android allows Widgets to be displayed on all 5 of your N1's home screens. Press the 'Menu' button, then Add, Widgets. If the 'Add' button is greyed out then you probably don't have enough space on the current home screen to add another widget, try swiping to another one first.

Shortcuts - You can easily add shortcuts on your home screens, not only to apps but also Contacts, Bookmarks, etc. Go to Menu, Add, Shortcuts

Folders - Very handy at keeping related shortcuts together. I have a Games folder on my desktop with shortcuts to all my games in it. To change the name of a folder, open it then long press on the current name, a change name dialog will appear.

Google Search box / Search button: This little box or button can do a whole lot. It searches contacts, applications and the internet. Try it out, also supports voice search.

You can find your Nexus's settings by pressing the 'Menu' button, then selecting 'Settings'. For example I go into Settings -> Wireless & Networks -> Wi-Fi Settings -> Press 'Menu' Button -> Advanced -> Wi-Fi sleep policy, and set it to Never as I have issues with the N1 failing to reconnect to our office Network. Then I manage when wifi is on or off with the pre-installed 'Power Control' home screen widget.

Auto Screen Brightness is useful at getting the best out of the N1's OLED screen and battery life, it is in Settings -> Sound & Display -> Brightness -> Automatic brightness

Allow non-market application downloading/side-loading by going to Settings -> Applications -> Unknown sources

Add a little security to your N1 by setting an unlock pattern in Settings -> Locations & Security -> Set unlock pattern. If you enter the wrong pattern too many times the phone locks up until you re-enter your G-Mail password.

Check for System updates from time to time in Settings -> About Phone -> System Updates

Also in 'About Phone' there is an item 'Battery use' which shows you a breakdown of which apps are using the most battery.

Market: This is your app-store now, get used to it. All the following apps are in there somewhere. NOTE: If you don't have a SIM card in your phone, or if the Android Market doesn't support payments in your country you will not see any paid apps. It's a feature.

Google Maps: Updates to this are delivered via the Market, the latest update right now includes Multi-Touch and Google Buzz.

Google Listen: Number 1 podcasting app for Android, search for your podcasts or import them and let it get on with it.

beebPlayer: iPlayer for UK Android users, awesome, amazing, thank you.

Weather Widget - Free by Android Apps: In my opinion the best looking weather widget in the Market, I use the 2x1 'Weather Small' varient.

Barcode Scanner: QR Codes are a decent way of transferring data between devices, if this is installed you can not only scan QR Codes but also create them from Contacts, Clipboard, Bookmarks or Applications.

Seesmic: My current fave Twitter client for Android

Flickr Droid: One of several Flickr uploaders, does a decent enough job and adds a Share to Flickr intent into the Gallery sharing options.

London City / London Tube: Both very valuable for someone who uses the London Underground frequently. Between them you get a decent map, line status's, routing and live departure boards (as widgets!)

Qik: If you're into Qik'ing, then the Android client is solid.

gTasks: Syncs with your G-Mail tasks lists if you have any.

Battery Widget: (Yes it is one of mine) I like to know the exact battery level so I have this widget on one of my screens.

Tech/News/Gossip/Gaming Buzz Widgets & Buzz Deck: A set of Widgets/Apps from us at Mippin to keep you upto date with the latest news in your chosen category.

Astro: My favourite file manager for Android, always in beta but works well.

MP3 Store: The Amazon MP3 store is preinstalled on the N1, has previews, special offers and can be a tad dangerous when drunk.

Shazam, Ultimate Stopwatch (me again), Compass, Urban Spoon, i-Music, Google Googles are all also worth checking out

Tower Defence games have taken off well on Android and there are quite a few around. The original was Plox, it is a year old now but worth a bash, the most popular is Robo Defence.

There are also many 'Flight Control' style games, my fave right now is 'Air Control', smooth gameplay, online scores and suitably difficult.

My top 3D games right now are Raging Thunder, Iron Sight, Breakout Legend

I still also like a good card game, there are loads.

Live Wallpapers
The Nexus 1 is the first Android device to support animated, interactive Wallpapers. Check out the preinstalled ones by pressing the 'Menu' Button, then Wallpaper, and Live wallpapers.

There are quite a few new ones now in the market including the 'Digital Rain' from the Matrix and my favourite 'Starfield 3D' which includes double tap for Hyper-space! I've knocked up 'Duck Paper' which is a Duck Hunt based Live Wallpaper, also available in the Market. We're intending on knocking a few more of these out over the next few weeks.

Rooting / Jail breaking

If you're top of your techy game and fancy being able to perform some more advanced functions on your Nexus 1 you need to get root access. Once done you'll be able to install apps for wired tether, wireless tether, screenshot, strobe light, boot animations, Apps to SD, no limits. You'll have super-user root access to your device in the terminal as well. The first stage of gaining root access is to unlock your bootloader, enabling the install of custom ROMs. Google were very clever about this and provided a simple method for doing it, but it warns you it will invalidate your warrenty and place an open padlock onto your boot screen.

I followed the guide over at Android & Me: http://androidandme.com/2010/01/hacks/video-how-to-unlock-and-root-a-nexus-one/

Thanks for reading and happy Android'ing

Wednesday, January 27, 2010

Android App Optimization: Using Reflection to test if an Android device is using 'Live Wallpapers'

I agree this may be a a pretty rare usecase, but I've just spent an hour figuring the details out so I thought it only polite to share them. Oneday, someone, somewhere may benefit.

What is Reflection?
It's been around almost as long as Java, described here and examples from Sun here

Why bother?
We've been receiving complaints that our Buzz Widgets are lagging on the Google Nexus One when Live Wallpapers are enabled. A little testing showed that this was down to the apps blurring out the desktop and rendering the content on top of it. If the desktop has a Live Wallpaper running on it, then blurring it eats some serious processor cycles. I understand that Reflection is more costly than directly calling the APIs, but this is just one simple call.

Why use reflection, not the actual API?
I'd much prefer to only have one version of each of our apps in the Android Market and the APIs for this only became available in the 2.1 SDK. Reflection enables us to use the APIs where available, whilst still letting the app run on devices with older firmwares.

Well to get to the point we want to perform the test

if(WallpaperManager.getInstance(this).getWallpaperInfo() != null){//Live Paper, don't blur}

To do this with Reflection we have to use the methods Class.forName(""), Class.getDeclaredMethod() and Object.invoke() a little like this:

boolean blurBackground = true;
//get the WallpaperManager Class
Class classWallpaperManager = Class.forName("android.app.WallpaperManager");
if(classWallpaperManager != null)
//find its .getInstance(this) method
Method methodGetInstance = classWallpaperManager.getDeclaredMethod("getInstance", Context.class);
//invoke the WallpaperManager's .getInstance(this) method to get one
Object objWallpaperManager = methodGetInstance.invoke(classWallpaperManager, this);

//discover the WallpaperManager Object's .getWallpaperInfo() Method
Method methodGetWallpaperInfo = objWallpaperManager.getClass().getMethod("getWallpaperInfo", null);
//invoke it
Object objWallPaperInfo = methodGetWallpaperInfo.invoke(objWallpaperManager, null);
Log.d("WidgetDroid","WallpaperInfo not null");

Also to ensure it is only run on Android 2.1+ devices I also wrap it in a quick Android Version check and a try/catch block for future safety:

Job done, now if the device is using a Live Wallpaper the apps background isn't blurred and all is well again in our Widget World.

Monday, January 25, 2010

The Android Market sweet spot & USW hits the 'final milestone'

The Ultimate Stopwatch & Timer for Android has just made it passed the 'final milestone' of 250,000 installs, great stuff. It's my second app to have reached the dizzy heights so far, the next is a couple of months away yet at around 150k. Seems like new device sales are keeping the install rates strong. Reaching 250k has a bizarre effect of dramatically increasing install rates. It is apparently a far more complelling proposition to install an app with >250k installs, almost as if the user starts believing they're missing out on something great. Battery Widget has rocketed from 250k to 450k installs in less than 2 months.

It seems, even though the Android Market is getting pretty busy these days, that if you focus on users desires it is still possible to get decent traction. Live Wallpapers are the sweet spot at the moment, they are being searched for by Nexus 1 users and a decent one will get thousands of downloads in the first week. I spent an hour creating 'Duck Paper' last week and it is now at 3,500 downloads. Content apps are a little trickier, especially if you don't have a recognised brand behind you, make them specific and easy to use, then update weekly.

Tuesday, January 12, 2010

Creating an Android 2.1 Live Wallpaper

Quick disclaimer: this isn't a tutorial, but a brief guide of what Live Wallpapers actually are and how I went about creating 'Duck Paper' - my first Android 2.1 Live Wallpaper. There are tutorials here, from Arno den Hond and here, from AndroGames.net

The Android 2.1 SDK was released today and the only major update was Live Wallpapers, so I thought I'd better find out what they are all about. What I found was quite surprising, I'd imagined that they would be some sort of animation or video playing on the desktop, a bit like MS DreamScene, but actually they are more akin to a an Android application open as the desktop. Live Wallpapers extend the WallpaperService class and the animations and interactions are handled in code, just like in a game. Realising this it seemed reasonable to try and port the only game I've written for Android, Duck Hunt, into a Live Wallpaper.

After less than an hour the first version of 'Duck Paper' was ready - as the ducks fly past in the background you can touch them to shoot them, then they fall off the screen.

Fortunately there is an example Live Wallpaper in the 2.1 SDK called CubeLiveWallpaper. This is definitely the starting point for anyone looking to create their own Live Wallpaper. I opened up this sample project, played with CubeLiveWallpaper1 and merged its Engine with Duck Hunt's SurfaceView code, et voila we have a Live Wallpaper.

Unfortunately I don't have an Android 2.1 device to try it on and it runs pretty slowly in the emulator. Once I've had it tested on a real device I'll put it in the Android Market.

Update: I've had it tested by a friend with a Nexus One and all seems well, so it is now live in the Android Market