Desi Programmer @ Work

Checking out AOSP Source Code in VirtualBox VM behind NAT

I recently spent a whole day trying to check out AOSP source code in a VirtualBox VM running Ubuntu 10.04 networked in NAT mode. There were minor issues but finding them and fixing them took a lot of time so I thought I should save some time for others.

I came across mainly two issues:

Firstly, I started getting GNU TLS handshake issues half the way through the check out process. I saw several such messages over and over everytime I tried to check out the code.

error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing https://android.googlesource.com/

It turns out that Google's Repo client now requires atleast version 1.7.2 while Ubuntu's repositories still have 1.7.0. Upgrading git using Git PPA solved the problem:

  • sudo add-apt-repository ppa:git-core/ppa
  • sudo apt-get update
  • sudo apt-get install git-core

However now I started running into some other issues: HTTP getting timed out or unable to resolve android.googlesource.com; it seemed like a throttling issue and it did turn out to be related to a bug in VirtualBox's NAT when accessed aggressively. I found two solutions

  1. Switch from NAT mode to Bridged mode networking for the VirtualBox VM.
  2. Change the NIC Adapter type from Intel to PCnet-FAST III Am79C973

The second option worked well for me since Bridged Mode requires more privileges on the host machine.