Monday, February 14, 2011

Install Android on an Original iPhone 2G

   I had a more difficult time figuring out how to get Android installed on my original iPhone 2G than I had expected. Beyond getting the Spirit jailbreak and Cydia installed I wasn't current on the whole jailbreak and iPhone dev scene, so I had to learn a lot. It only took one night to get iDroid installed though, and most of that time was spent doing things wrong and restoring the iPhone to factory settings after I (or Cydia!) screwed up. Here's the process I went through to get a working copy of Android running.

   Because I had already jailbroken my iPhone with Spirit I decided to restore my iPhone to stock settings. This is because Spirit is a userspace-level jailbreak and the Bootlace tool, which is the simplest way to install iDroid, doesn't support it. Only pwnagetool, blackra1n, and redsn0w work with Bootlace. Since I had no sim card installed when I tried to restore the iPhone I ended up with a phone that wasn't activated and so couldn't even be used as an iPod. This was something I hadn't expected. It was my own fault for not reading more I guess, and it was the first big setback of the night.

   I searched for ways to get my iPhone running again without a sim card or activation and found that blackra1n could "hacktivate" it. Since I needed to run a Bootlace-supported jailbreak anyway, and redsn0w had failed to work for me previously, I rebooted into Windows to use blackra1n. That's when I ran into the second problem, blackra1n wouldn't run. Further use of Google solved this, I simply placed the blackra1n executable into the Program Files\Common Files\Apple\Apple Application Support folder which contains the ASL.dll file blackra1n needed to run. Then I tried running blackra1n again and it failed to do anything. This was a smack-my-head moment. I ended up having to put the phone into DFU mode, downgrade from the 3.1.3 firmware the phone was running to 3.1.2 (by running iTunes and holding down shift when I selected "Restore" to select the 3.1.2 firmware ipsw file I downloaded from here) and finally blackra1n ran correctly. Once blackra1n did its magic I used the blackra1n app on the phone to install Cydia and experienced the third frustrating problem that night.

   I had a hell of a time with Cydia crashing immediately after updating itself. It wouldn't start up after the first time and my attempts to find some way to fix it were fruitless. I tried wiping the phone and going through the jailbreak process again, as well as trying to use various iPhone file browsers in Windows to clear the Cydia package cache. In frustration I ran the Spirit jailbreak on top of blackra1n and that apparently installed a fresh copy of Cydia. That new copy worked properly. After Cydia finished updating itself I was able to install and use Bootlace to install the new bootloader and iDroid. Finally!

   Android isn't useable for much on an iPhone currently, the wifi doesn't work well and there's no Market or bundled Google Apps, but I was able to install Angry Birds manually with adb. Too bad it crashes on startup. There's apparently very limited access to the hardware on the iPhone when running Android, so things like video and 3D games aren't an option, but this is a work in progress so I hope things will improve over time. At least I have a way to try out Android without having to borrow someone else's phone, and I can start writing simple programs without having to touch the slow Android emulator.

   For a start in Android app development I was able to load the "Hello Android" example onto the iDroid and run it successfully. A small step towards improving my Java and porting my simplest game over to Android, and yet another distraction from my other projects. I just can't seem to focus on learning any one programming language or technology subject for very long.

No comments:

Post a Comment