How can I manually install the Android Support libraries required by the Xamarin.Android.Support packages?

PDF for offline use

Let us know how you feel about this

Translation Quality


0/250

Example steps for Xamarin.Android.Support.v4 on Windows

  1. Download the desired Xamarin.Android.Support NuGet package (for example by installing it with the NuGet package manager).
  2. Use ildasm to check which version of android_m2repository\*.zip the NuGet package needs:

    ildasm /caverbal /text /item:Xamarin.Android.Support.v4 packages\Xamarin.Android.Support.v4.23.4.0.1\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll | findstr SourceUrl

    Example output:

    property string 'SourceUrl' = string('https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip')
    property string 'SourceUrl' = string('https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip')
    property string 'SourceUrl' = string('https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip')
  3. Download the android_m2repository*.zip file from Google using the URL from step 2.

    Alternative: You can check which version of the Android Support Repository you currently have installed in the Android SDK Manager:

    "Android SDK Manager showing Android Support Repository version 32 installed"

    If the version matches the one you need for the NuGet package, then you don't have to download anything new. You can instead re-zip the existing m2repository directory that is located under extras\android in the SDK Path (as shown the top of the Android SDK Manager window).

  4. Calculate the MD5 hash of the URL from step 2. Format the resulting string to use all uppercase letters and no spaces. For example, adjust the $url variable as needed and then run the following 2 lines (based on the original C# code from Xamarin.Android) in PowerShell:

    $url = "https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip"
    (([System.Security.Cryptography.MD5]::Create()).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($url)) | %{ $_.ToString("X02") }) -join ""

    Example output:

    F16A3455987DBAE5783F058F19F7FCDF
  5. Copy the .zip file from step 3 into the "%LOCALAPPDATA%\Xamarin\zips\" folder. Rename the file to use the MD5 hash from step 4. For example:

    "%LOCALAPPDATA%\Xamarin\zips\F16A3455987DBAE5783F058F19F7FCDF.zip"

  6. (Optional) Unzip the file into "%LOCALAPPDATA%\Xamarin\Xamarin.Android.Support.v4\23.4.0.0\content\" (creating a content\m2repository subdirectory). If you skip this step, then the first build that uses the library will take a little longer because it will need to complete this step.

    The version number for the subdirectory (23.4.0.0 in this example) is not quite the same as the NuGet package version. You can use ildasm to find the correct version number:

    ildasm /caverbal /text /item:Xamarin.Android.Support.v4 packages\Xamarin.Android.Support.v4.23.4.0.1\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll | findstr /C:"string 'Version'"

    Example output:

    property string 'Version' = string('23.4.0.0')}
    property string 'Version' = string('23.4.0.0')}
    property string 'Version' = string('23.4.0.0')}

Example steps for Xamarin.Android.Support.v4 on Mac

  1. Download the desired Xamarin.Android.Support NuGet package (for example by installing it with the NuGet package manager).

  2. Double-click the Xamarin.Android.Support.v4 assembly under the References section of the Android project in Visual Studio for Mac to open the assembly in the Assembly Browser. Ensure that the Language drop-down is set to C# and select the top-level Xamarin.Android.Support.v4 assembly from the Assembly Browser navigation tree. Locate the SourceUrl property under one of the IncludeAndroidResourcesFrom or JavaLibraryReference attributes:

    [assembly: IncludeAndroidResourcesFrom ("./", PackageName = "Xamarin.Android.Support.v4", SourceUrl = "https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip", EmbeddedArchive = "m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar", Version = "23.4.0.0")]
  3. Download the android_m2repository*.zip file from Google using the SourceUrl from step 2.

    Alternative: You can check which version of the Android Support Repository you currently have installed in the Android SDK Manager:

    "Android SDK Manager showing Android Support Repository version 32 installed"

    If the version matches the one you need for the NuGet package, then you don't have to download anything new. You can instead re-zip the existing m2repository directory that is located under extras/android in the SDK Path (as shown the top of the Android SDK Manager window).

  4. Calculate the MD5 hash of the URL from step 2. Format the resulting string to use all uppercase letters and no spaces. For example, adjust the URL string as needed and then run the following command in a Terminal.app command prompt:

    echo -n "https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip" | md5 | tr '[:lower:]' '[:upper:]'

    Alternative: Another option is to use the csharp interpreter to run the same C# code that Xamarin.Android itself uses. To do that, adjust the url variable as needed and then run the following command in a Terminal.app command prompt:

    csharp -e 'var url = "https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip"; string.Concat((System.Security.Cryptography.MD5.Create().ComputeHash(System.Text.Encoding.UTF8.GetBytes(url))).Select(b => b.ToString("X02")))'

    Example output:

    "F16A3455987DBAE5783F058F19F7FCDF"
  5. Copy the .zip file from step 3 into the "$HOME/.local/share/Xamarin/zips/" folder. Rename the file to use the MD5 hash from step 4. For example:

    "$HOME/.local/share/Xamarin/zips/F16A3455987DBAE5783F058F19F7FCDF.zip"

  6. (Optional) Unzip the file into "$HOME/.local/share/Xamarin/Xamarin.Android.Support.v4/23.4.0.0/content/ (creating a content/m2repository subdirectory). If you skip this step, then the first build that uses the library will take a little longer because it will need to complete this step.

    The version number for the subdirectory (23.4.0.0 in this example) is not quite the same as the NuGet package version. As in step 2, you can use the Assembly Browser in Visual Studio for Mac to find the correct version number. Look for the Version property under one of the IncludeAndroidResourcesFrom or JavaLibraryReference attributes:

    [assembly: IncludeAndroidResourcesFrom ("./", PackageName = "Xamarin.Android.Support.v4", SourceUrl = "https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip", EmbeddedArchive = "m2repository/com/android/support/support-v4/23.4.0/support-v4-23.4.0.aar", Version = "23.4.0.0")]

Additional references

  • Bug 43245 – Inaccurate "Download failed. Please download {0} and put it to the {1} directory." and "Please install package: '{0}' available in SDK installer" error messages related to Xamarin.Android.Support packages

Next Steps

This document discusses the current behavior as of August 2016. The technique described in this document is not part of the stable testing suite for Xamarin, so it could break in the future.

For further assistance, to contact us, or if this issue remains even after utilizing the above information, please see What support options are available for Xamarin? for information on contact options, suggestions, as well as how to file a new bug if needed.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.