Archive for the ‘android’ Category

Low powered web servers and resolving issues installing Ubuntu on an Android Galaxy S

Posted on November 21st, 2011 in android, Linux | 2 Comments »

I’ve been on a multi-month long side project trying to create a low powered web server for hosting an offline version of Wikipedia in the dessert (long story). I assembled my own machine from Newegg but even with solid-state it was running between 30-50 watts.

My latest approach has been modifying a Linksys NSLU2, an old low-powered network storage device, and installing Debian on it (thanks to great documentation from the NSLU/Linux community). The end product is a web server that runs between 3-5.5 watts! And it’s able to support two usb drives. Not the fastest machine but certainly useable, especially at the cost of only $35 used for the device off Craigslist (compared also to the $225 or so I spent assembling the machine above.)

While I think it’s the approach I’m going to go with, I found a link where someone installed Ubuntu on their Android device. This piqued my interest as it’s also a low wattage device (and the fact that I have a Galaxy S sitting around doing nothing.) I followed the steps, and though it worked well, the Ubuntu package manager has problems when you want to install any new packages or do an update. It just 404′s like so:

Err http://ports.ubuntu.com karmic/main Packages
  404  Not Found

After much research I ended up having to change /etc/apt/sources.list from:

deb http://ports.ubuntu.com/ubuntu-ports karmic main universe

to:

deb http://old-releases.ubuntu.com/ubuntu/ karmic main universe

I tried to post this update to the blog above but it errored out, so I’m leaving the solution here instead should anyone else have the issue.

Additional note In the case of the NSLU2: if DHCP has assigned the Slug an ip address but your wireless router doesn’t find it, use nmap to ping for port 22 on your subnet:

nmap -p 22 --open -sV 10.0.0.0/24

Setting up remote JavaScript debugging for mobile devices in minutes with Weinre

Posted on April 1st, 2011 in android, iOS, iPhone, mobile apps | No Comments »

Let’s face it. Mobile web development today sucks. You don’t get the fancy console and debugging tools you have in modern desktop browsers like Firebug or Webkit’s Inspector. At most, you can enable a simple debug tab that reports the number of JS errors and allows you to console.log one variable at a time—and if you’re using embedded web views you don’t even get that much. For anything else you pretty much have to revert to the old days of javascript popup alerts or tailing your server logs.

Enter Weinre. Weinre is a beta project written in Java that allows you to have a remote Webkit inspector-style debugging console on your desktop that can communicate with your mobile device. You can send alerts, do full console logging—even inspect the remote DOM tree. It’s in beta and occasionally a little buggy but totally useable.

To use it, run the java server on your local machine and add a single script tag to your project. You can also just download the Mac executable here. The full documentation is here – (its not very straightforward so post here if you have questions.)

At work, we use Charles to redirect production apps to our local dev server. My local server.properties file looks like this:

~/.weinre]$ cat server.properties 
boundHost -all-
httpPort: 8081
reuseAddr: true
readTimeout: 1

Thanks goes to coworker Jim for being the first Guinea Pig to try it out.

The Android’s greatest flaw for developers and consumers alike: lack of web proxy

Posted on March 21st, 2011 in android | 1 Comment »

Update 6/17/2011: I received an email from GoogleCode that nonchalantly mentions that this feature has been added to Honeycomb (3.0). I confirmed that the ticket status is now changed to “released”. While it’s great that this feature is finally here, I wish that they had made more of a public announcement or address as to why it took so long. As of 14 hours ago ticket 1273 is still receiving plenty of comments (400 more since this post was written) and has been starred 3812 times. Google acquired the company that started Android over six years ago and I consider the lack of communication an utter failure.

Taken during the Q&A session at SV IGDA Game Technology and Career Night at Google March 16, 2010.

There’s endless amounts of comparisons between the iPhone and Android phones regarding which is better. While I prefer to stay out of that debate, it can’t be ignored that the Android platform lacks a built-in web proxy—and for over two years running now.

As a mobile web developer, this makes development increasingly hard as embedded web views inside of games and other mobile applications can’t be rerouted to your local machine easily. There’s no immediate way of analyzing or redirecting HTTP requests, using Charles, or other standard ways of debugging. Sure there’s hacks out there to install custom roms, modify the IP tables of your router, or use the Android SDK to modify the phone’s etc host—but none of them work as cleanly and efficiently as a simple option under system settings or at all in cases like my own where we need to redirect production requests to a remote dev server. My company had to actually spend developer time to build a web proxy option inside our Android-port of our iOS game for just this.

Consumers also are affected by this lack of proxy. Many secure corporations and college networks require you to set up a web proxy to access internal resources. View the sea of complaints on the official Android ticket, over 1,300 comments strong and mostly consumers. While 1,300 might not sound like a lot for a platform as far-reaching as Android, that’s only the people savvy enough to know what a bug tracking system is and how to use it.

In short, the Android platform is becoming the new IE for us and consumers. If you use or develop on an Android and would like this missing feature prioritized, please visit this link and star the post. Feel free to leave a comment. Then tweet it up: “Google: please fix Android issue 1273. We need a web proxy! http://code.google.com/p/android/issues/detail?id=1273″. Feel free to link to this post as well for a quick explanation of the situation.

Thanks.

Android web development: Solution for failed ajax calls

Posted on February 23rd, 2011 in android | No Comments »

A port of an iOS game with web views wasn’t working fully on Android devices. I spent a full day debugging this, looking at everything from cross-client / domain issues, bad caching, to other client-related code differences – it’a all webkit right, it shouldn’t be too hard? Something one quickly learns is that web development in Android is 10x harder / slower than iOS since it takes more effort to close apps outright and, most importantly, there isn’t a direct way to set a web proxy (so no HTTP debugging outside of the 1992-era approach of tailing logs on your server.)

Google is aware of this lack of proxy issue as apparent by the bug logged back in 2008 with a few hundred angry comments (and more being added each week). In the meantime Android is quickly becoming the new IE for me.

Anyways, the problem ended up being resolved by commenting out these two lower level ajax settings. iOS works without them, too.

/* self.xhr.setRequestHeader("Content-length", params.length); */
 /* self.xhr.setRequestHeader("Connection", "close"); */