Android Studio Debugging with Nexus 4 Google Driver

Recently I’ve been thinking of dipping my toe back into the world of Android app development and discovered that there is a new IDE on the block in the form of the Android Studio.

I installed this on my (Windows) machine, which isn’t a speed demon by any stretch of the imagination, and tried to run a “Hello World!” program on the emulator but it was taking 10 minutes for the emulator to start and it was still just showing the android boot screen, so I decided to try it out on my Nexus 4.

I followed the standard advised steps, enabling USB debugging and setting the USB mode to PTP, but the phone didn’t appear when I connected it and went to Run the package from Android Studio.  Further, the drivers wouldn’t install properly.  Advice seemed to be to go to Device Manager and install from <sdk>\extras\google\usb_driver\ – but there was no usb_driver folder there.  However you can  install this from the “SDK Manager” from the Android Studio toolbar.

Screenshot of Android Studio toolbar highlighting SDK Manager button
SDK Manager button on Android Studio toolbar

This will open the SDK Manager which seems to contain optional components that you can install alongside the Android Studio.  In this case I was looking for the Google USB Driver which is listed under “Extras”.

Continue reading “Android Studio Debugging with Nexus 4 Google Driver”

Updating Subversion on Lubuntu 12.04

I’m trying to get reacquainted with Subversion having not used it since my student days and was happy to find it was already installed on my Lubuntu 12.04 (either by default or because I’d previously installed it).

What I didn’t immediately realise was that the version installed was neither the latest (1.8) or the latest stable (1.7) version, but 1.6.  (You can check the version of the installed SVN server using the command svnadmin --version

Since I have automatic updates on I thought that was a bit strange so got to Googling and came across Kovstantin Kovshenin’s post Subversion 1.7 on Ubuntu 12.04 which helped.

Essentially I needed to add a couple of lines to my /etc/apt/sources.list file to reference a PPA from launchpad.

deb precise main
deb-src precise main

and then update subversion using apt-get at the command line:

sudo apt-get update
sudo apt-get install subversion

This is the point in the instructions where I hit a problem, getting the error message:

W: GPG error: jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY XXXXXXXXXXXXXXXX

Where XXXXXXXXXXXXXXXXX is a string of hex characters. The solution, as described here, was to update the list of GPG keys stored by Lubuntu using the command

sudo apt-key adv --keyserver --recv-keys XXXXXXXXXXXXXXXX

Doing this and repeating the update commands above solved my problem, and rerunning the version check presented me with:

svnadmin --version
svnadmin, version 1.7.9 (r1462340)
compiled Apr 6 2013, 21:23:46

Adding DNS Server to Lubuntu 12.04 with Webmin

I’m trying to set up my Lubuntu box as a test server for some web development (PHP) work and have decided this means running a DNS server so I can set up my own domain names (site1.local, site2.local etc).

A quick Google suggests installing and configuring a DNS server manually could be painful, and it looks as though the simplest way to do this would be to use Webmin*, a web based interface for administering Unix-like systems.

Unfortunately when I followed the Webmin install instructions I got an error telling me that:

W: Failed to fetch Unable to find expected entry ‘contrib/source/Sources’ in Release file (Wrong sources.list entry or malformed file)

W: Failed to fetch Unable to find expected entry ‘contrib/source/Sources’ in Release file (Wrong sources.list entry or malformed file)

Looking at the messages you can see it is failing to find some files called “sources”, which explains why the solution I found at SuperUser worked.  Just tell apt-get to stop looking for sources!  When you add the repositories in the install instructions, it looks like Linux is adding the corresponding source repositories, when all we really want are the binaries to run the program.  So you can either manually edit /etc/apt/sources.lst and comment out the offending lines (which should be at the end of the file and prefixed with deb-src) – or you can use Ubuntu’s “Software Sources” utility and just remove them.

Now you can run apt-get install webmin again and it should be fine.

* Actually, the simplest way is probably to just edit the HOSTS file on my laptop(s) as I’ve done previously, but I’m trying to do this in some way ‘right’.

Using Body OnLoad with SharePoint (2010)

I spent a decent amount of time trying to workaround not being able to access the body onload event of a SharePoint page, including looking at adding JavaScript event handlers programatically, before I came across this… almost an aside in another article.

In order to work around this limitation, SharePoint provides the “_spBodyOnLoadFunctionNames” array. When the body is loaded, the onload event handler executes each function whose name is contained in this array.

So apparently all one has to do to have a JavaScript function execute when the body loads is to add the name of the function (as a string) to that array, a la _spBodyOnLoadFunctionNames.push("functionName"); – simples!


In the end we just wanted to do to much for simple JavaScript so used the awesome jQuery library – which includes the $(document).ready() method to take care of that, but I’m sure the above will help somebody, somewhere, some day.

Android/Facebook/Eclipse – Must Override a Superclass Method

I’m trying to get into developing apps for Android and developing an Android Facebook app seemed like an good place to start with something useful.  However it seems frought with problems that will perplex the beginner.

One early problem I encountered which had a non-0bvious solution was the message:

The method onCancel() of type new Facebook.DialogListener(){} must override a superclass method

This occurred after pasting some example code from the Facebook site into my project.  The problem?  My project was defaulting to JDK 1.5 and the code on the Facebook site requires 1.6!

It’s been a while since I looked at Java but the problem is apparently due to the use of the “@override” syntax. According to one helpful StackOverflow member, in Java 1.6 this can also be used to implement interface methods, but in 1.5 could only be used to override superclass methods.

Eclipse/Android Development Installation Issue

Yes, it’s Christmas as I blog this at 2am, however I got a new laptop for Christmas and am geeking it out to the point where I can use it for fun stuff.  To that end I’ve been trying to install the requisite tools for Android development and hit an issue which could have (but thankfully didn’t) take me hours to sort out.  I’m a complete n00b at this, so don’t treat this as anything like a complete guide!

Having managed to “install” Eclipse (which from what I can tell just means copying the contents of a zip file to somewhere on your hard drive) and the Android SDK, I needed to install the ADT (Android Development Tools) plugin for Eclipse.  However on doing this I was getting an error telling me:

Missing requirement: Android Development Toolkit 0.9.4.v200910220141-17704 ( 0.9.4.v200910220141-17704) requires ‘bundle org.eclipse.gef 0.0.0’ but it could not be found

This was a pain, and it took a bit of Googling to discover how to rectify that. Apparently the version of Eclipse Google recommend (Classic) doesn’t include the GEF or ‘Graphical Editing Framework’ which the Android ADT plugin requires.  Nice!  So the easy way to install this (thank you to IBM for the pointer on this) is to install it the same way you would the ADT plugin, i.e. open up Eclipse and choose “Install New Software” in the “Help” menu.

When it says work with, instead of using the URL Google give for Android, use the one where GEF lives.  In my case, for version 3.6.x of Eclipse, this is:

Helios –

(Helios being the codename for Eclipse 3.6).  Once this is done you’ll be advised to restart Eclipse (so I did) and everything seems to be going ok now (touch wood!).

I just hope this helps someone else with the same problem or, more importantly, helps me the next time I come across the same thing and end up scratching my head trying to remember how I fixed it!

nerd. links – LDAP Browser

Had a bitch of a day today in work, with an application I was playing with refusing to play with Active Directory (largely because I’ve never used LDAP before and couldn’t figure out the weird bloody syntax).

So I’d really like to offer a quick thank you to Jarek Gawor for developing (and releasing) his LDAP Browser/Editor which let me double check that I was connecting to the right server/port and play with the settings enough that I eventually got it sussed. Great wee Java tool.

Screenshot of LDAP Browser/Editor

Big PHP Niggle

I need a quick bitch.

I love PHP. It’s everywhere. All my sites are written in it. My CMS is written in it. My blog engines, WordPress and b2evolution, are written in it. It’s free. It runs on any platform. Hosts all support it. With PHP 5 they’ve even done a lot of work on PHP4’s main downfall – lack of OOP support.

One thing really pisses me off though – it’s totally inconsistent.  Consider these two functions:

  1. strstr — Find first occurrence of a string
  2. in_array — Checks if a value exists in an array

Take a close look. See the signatures?

string strstr ( string $haystack , mixed $needle [, bool $before_needle ] )
bool in_array ( mixed $needle , array $haystack [, bool $strict ] )

In in_array the first parameter is what you’re looking for and the second is what you’re looking in (more or less consistent with preg_match).  In strstr (and its derivatives) this order is reversed. Who on Earth let that slip through? I’m yet to find a free text editor that will tell you which parameters a given function expects (Dreamweaver does a decent job but it’s bloody expensive for a text editor!) the way Visual Studio does for C#, which I use a lot in work.  Given that situation, you’d expect consistency in this sort of thing.  Apparently not so. Instead, every time I want to use one of these functions I have to do a quick Google to bring me to the PHP manual page to tell me which order the parameters come in.

Of course they can’t even fix that without breaking backwards compatibility either, so we’re probably stuck with it.  Bloody marvellous!

I Can Has Vista Sidebar Gadget?

O hai!

I hart lolcatz.

I hart lolcatz so much dat wun dai I thoughted “I can has lolcatz wen I makes teh pooter turn on?” So I maded a Vista gadjit an now I has new lolcatz every dai.

If u hart lolcatz liek mee an wants lolcatz in ur pooter makin u laff, downlodes mah gadjit. I has tested it 4 liek rly long time. It rly works, srsly.

An evry1 needses moar lolcatz.


Continue reading “I Can Has Vista Sidebar Gadget?”