Resolving Library Installation Errors
- PDF for offline use
Let us know how you feel about this
last updated: 2017-06
In some cases, you may get errors while installing Android support libraries. This guide provides workarounds for some common errors.
- Errors While Downloading m2Repository
While building a Xamarin.Android app project, you may get build errors when Visual Studio or Xamarin Studio attempt to download and install dependency libraries. Many of these errors are caused by network connectivity issues, file corruption, or versioning problems. This guide describes the most common support library installation errors and provides the steps to work around these issues and get your app project building again.
Errors While Downloading m2Repository
You may see m2repository errors when referencing a NuGet package of the Android Support Libraries or Google Play services. The error message resembles the following:
Download failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r16.zip and extract it to the C:\Users\mgm\AppData\Local\Xamarin\Android.Support.v4\22.2.1\content directory.
This example is for android_m2repository_r16, but you may see this same error message for a different version such as android_m2repository_r18 or android_m2repository_r25.
Automatic Recovery from m2repository Errors
Often, this issue can be remedied by deleting the problematic library and rebuilding according to these steps:
Navigate to the support library directory on your computer:
On Windows, support libraries are located at C:\Users\username\AppData\Local\Xamarin.
On Mac OS X, support libraries are located at /Users/username/.local/share/Xamarin.
Locate the library and version folder corresponding to the error message. For example, the library and version folder for the above error message is located at Android.Support.v4\22.2.1:
Delete the contents of the version folder. Be sure to remove the .zip file as well as the content and embedded subdirectories within this folder. For the example error message shown above, the files and subdirectories shown in this screenshot (content, embedded, and androidm2repositoryr16.zip) are to be deleted:
Note that it is important to delete the entire contents of this folder. Although this folder may initially contain the "missing" android_m2repository_r16.zip file, this file may have been partially downloaded or corrupted.
Rebuild the project – doing so will cause the build process to re-download the missing library.
In most cases, these steps will resolve the build error and allow you to continue. If deleting this library does not resolve the build error, you must manually download and install the android_m2repository_rnn.zip file as described in the next section.
Manually Downloading m2repository
If you have tried using the automatic recovery steps above and still have build errors, you can manually download the android_m2repository_rnn.zip file (using a web browser) and install it according to the following steps. This procedure is also useful if you do not have internet access on your development computer but you are able to download the archive using a different computer.
Download the android_m2repository_rnn.zip file that corresponds to the error message – links are provided in the following list (along with the corresponding MD5 hash of each link's URL):
android_m2repository_r33.zip – 5FB756A25962361D17BBE99C3B3FCC44
android_m2repository_r32.zip – F16A3455987DBAE5783F058F19F7FCDF
android_m2repository_r31.zip – 99A8907CE2324316E754A95E4C2D786E
android_m2repository_r30.zip – 05AD180B8BDC7C21D6BCB94DDE7F2C8F
android_m2repository_r29.zip – 2A3A8A6D6826EF6CC653030E7D695C41
android_m2repository_r28.zip – 17BE247580748F1EDB72E9F374AA0223
android_m2repository_r27.zip – C9FD4FCD69D7D12B1D9DF076B7BE4E1C
android_m2repository_r26.zip – 8157FC1C311BB36420C1D8992AF54A4D
android_m2repository_r25.zip – 0B3F1796C97C707339FB13AE8507AF50
android_m2repository_r24.zip – 8E3C9EC713781EDFE1EFBC5974136BEA
android_m2repository_r23.zip – D5BB66B3640FD9B9C6362C9DB5AB0FE7
android_m2repository_r22.zip – 96659D653BDE0FAEDB818170891F2BB0
android_m2repository_r21.zip – CD3223F2EFE068A26682B9E9C4B6FBB5
android_m2repository_r20.zip – 650E58DF02DB1A832386FA4A2DE46B1A
android_m2repository_r19.zip – 263B062D6EFAA8AEE39E9460B8A5851A
android_m2repository_r18.zip – 25947AD38DCB4865ABEB61522FAFDA0E
android_m2repository_r17.zip – 49054774F44AE5F35A6BA9D3C117EFD8
android_m2repository_r16.zip – 0595E577D19D31708195A83087881EE6
If the m2repository archive is not shown in this table, you can create the download URL by prepending https://dl-ssl.google.com/android/repository/ to the name of the m2repository to download. For example, use https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip to download android_m2repository_r10.zip.
Rename the file to the corresponding MD5 hash of the download URL as shown in the above table. For example, if you downloaded android_m2repository_r25.zip, rename it to 0B3F1796C97C707339FB13AE8507AF50.zip. If the MD5 hash for the download URL of the downloaded file is not shown in the table, you can use an online MD5 generator to convert the URL to an MD5 hash string.
Copy the file to the Xamarin zips folder:
On Windows, this folder is located at C:\Users\username\AppData\Local\Xamarin\zips.
On Mac OS X, this folder is located at /Users/username/.local/share/Xamarin/zips.
For example, the following screenshot illustrates the result when android_m2repository_r16.zip is downloaded and renamed to the MD5 hash of its download URL on Windows:
If this procedure does not resolve the build error, you must manually download the android_m2repository_rnn.zip file, unzip it, and install its contents as described in the next section.
Manually Downloading and Installing m2repository Files
The fully manual process for recovering from m2repository errors entails downloading the android_m2repository_rnn.zip file (using a web browser), unzipping it, and copying its contents to the support library directory on your computer. In the following example, we'll recover from this error message:
Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r25.zip and extract it to the C:\Users\mgm\AppData\Local\Xamarin\Android.Support.v4\23.1.1\content directory.
Use the following steps to download m2repository and install its contents:
Delete the contents of the library folder corresponding to the error message. For example, in the above error message you would delete the contents of C:\Users\username\AppData\Local\Xamarin\Android.Support.v4\18.104.22.168. As described earlier, you must delete the entire contents of this directory:
Download the android_m2repository_rnn.zip file from Google that corresponds to the error message (see the table in the previous section for links).
Extract this .zip archive to any location (such as the Desktop). This should create a directory that corresponds to the name of the .zip archive. Within this directory, you should find a subdirectory called m2repository:
In the versioned library directory that you purged in step 1, re-create the content and embedded subdirectories. For example, the following screenshot illustrates content and embedded subdirectories being created in the 22.214.171.124 folder for android_m2repository_r25.zip:
Copy m2repository from the extracted .zip into the content directory that you created in the previous step:
In the extracted .zip directory, browse to m2repository\com\android\support\support-v4 and open the folder corresponding the version number created above (in this example, 23.1.1):
Copy all of the files in this folder to the embedded directory created in step 4:
Verify that all files are copied over. The embedded directory should now contain files such as .jar, .aar, and .pom.
At this point, you have manually installed the missing components and your project should build without errors. If not, verify that you have downloaded the m2repository .zip archive version that corresponds exactly to the version in the error message, and verify that you have installed its contents in the correct locations as described in the above steps.
This article explained how to recover from common errors that can take place during the automatic download and installation of dependency libraries. It described how to delete the problematic library and rebuild the project as a way to re-download and re-install the library. It described how to download the library and install it in the zips folder. It also described a more involved procedure for manually downloading and installing the necessary files as a way to work around issues that cannot be resolved via automatic means.