Sunday 21 January 2018

Moving Xamarin's Android dependencies off your Primary drive

The other day I wanted to get the latest android SDK, but due to insufficient space on my primary drive this failed.

What follows is the process by which you can get from this situation into one where you can have as many SDKs and Android Virtual Devices as you want (as long as you have somewhere other than your primary drive to park it).

First, make sure you are fixing the right problem.

Just because our drive is too full to accommodate any more SDK artifacts or create a new AVD, that doesn't mean they themselves are to blame. So let's find out before we go any further.

Running a utilities like WinDirStat, TreeSize (etc) will quickly show you what your disk fillers are.
For me the biggest culprits were the android SDK and my AVD's (hence the blog post).


Moving the SDKs

Moving the SDKs is pretty straight forwards, in your IDE you will find the settings for Xamarin, including the location of the Android SDK's.

Visual Studio - Options menu.
  • Go to this location and copy the Android folder (containing the SDKs) to your secondary drive.
  • Update the reference in your IDE.

Once done, you should see that when you open your 'SDK manager'. The being used should now be the new one that you defined in the previous step.


  • Delete the original Android SDK folder from your primary drive, to free up some space.


Moving the AVDs

Let's see if we can make more room by moving those AVD files...

  • Add the following key to your environment variables
    ANDROID_SDK_HOME
  • Assign it a value of where you would like your .android folder to live, eg.
    F:\AndroidDevices

If you want to use your existing devices, copy your existing .android folder from your primary drive to this location.

This variable will kick in after a restart.
You can verify that this change has been applied by Opening your AVD manager from Visual Studio and looking at the address at the top line.