Compiling the Android emulator

If you have followed my recent posts, you may be aware that the only thing left in my evil plans to dominate the world was getting an updated version of the emulator.

It's not the first time I attempt to build Android from the source code, and I was scared that it wouldn't work this time either. So I followed again the instructions in their website, installed repo, requested it to get the source, waited, and then compiled everything (waiting a bit more in the meantime). Because I had tried already to do this, all the build dependencies were fulfilled and I could build everything with no problem, even if I'm running Ubuntu 64 bits :)

But then I reached the usual blocking point: how to run the newly compiled emulator? If I change to its directory and try to run it from there, it complains about ANDROID_* constants not being defined. In previous attempts I had tried all sorts of combinations to make it work, and never managed to. Then it seems the idea bulb decided to turn on, and I thought: well, why don't I just copy the new binary into the SDK folder that Eclipse points to?

I made a backup of the old emulator executable, just in case, and copied the new build into that directory. Then booted up Eclipse and started the emulator. It worked! Would it get the proper coordinates this time? I tried again with the same GPS points I had recorded in my previous post, and I got a different result: instead of teletransporting me a few streets away, it directly placed me directly onto the Thames river :-D

Well, that must be definitely the reason why someone posted a fix for the fix, I immediately thought. But now that I knew how to use my own builds of the emulator, I just had to patch the code with the suggested patch, recompile and try again with the new build. Which I did, and I'm happy to confirm that it worked! No more appearing over buildings or navigating the Thames without a boat! \o/

Another good thing is that once the code base has been already compiled, if you do a change it's intelligent enough to not to recompile everything, but only the modified components. So well done, Android engineers. Now you just need to make clearer how to actually use/navigate the source code for people who didn't write it and maybe you'd get more patches :-P