18

I recently uploaded my project to Git, and used a auto-generated Xamarin/Windows/MacOS/VisualStudio .gitignore file. I did a lot of work and testing on iOS, but now I'm coming back to android but upon building the Project.Droid version, I get the following errors:

Error   11  Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\embedded\./ doesn't exist.    MyProject.Droid
Error   5   Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\embedded\classes.jar doesn't exist.    MyProject.Droid
Error   8   Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\embedded\libs/internal_impl-21.0.3.jar doesn't exist.  MyProject.Droid
Error   4   Reason: C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\android_m2repository_r10.zip is not a valid zip file   MyProject.Droid
Error   7   Reason: C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\android_m2repository_r10.zip is not a valid zip file   MyProject.Droid
Error   10  Reason: C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\android_m2repository_r10.zip is not a valid zip file   MyProject.Droid
Error   3   Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content directory.   MyProject.Droid
Error   6   Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content directory.   MyProject.Droid
Error   9   Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content directory.   MyProject.Droid

Does anyone know how can I fix it? I checked my SDK Manager using admin rights and I already have the Android Support Library installed

sgarcia.dev
  • 5,671
  • 14
  • 46
  • 80
  • 2
    [This](http://stackoverflow.com/a/31794119/1155650) is what worked for me, even though issue i was having was with 23.0.1 – Rohit Vipin Mathews Oct 15 '15 at 05:14
  • 1
    Xamarin has a nice helpfull guide to solve this issue for any version you are using. Take a look here: https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/#Manually_Downloading_m2repository – Ton Snoei Feb 02 '17 at 14:15

13 Answers13

24

The error message tells you pretty explicitly

  1. what the error is

    C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\android_m2repository_r10.zip is not a valid zip file

  2. How to fix it

    Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content directory.

Jason
  • 86,222
  • 15
  • 131
  • 146
  • My bad, I got scared by the first error "...\embedded\./ doesn't exist." and figured the missing Android.Support.v4 couldn't be the problem because the SDK manager already had it instaled. Thank you very much – sgarcia.dev May 25 '15 at 17:40
  • 11
    you can delete every thing in side the folder C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\ and Xamarin will automaticly downloaded again – Mohamed Elrashid Jun 17 '15 at 18:26
  • @Jason it didn't work for me :( I downloaded https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extracted it and add it to C:\Users\MYUSER\AppData\Local\Xamarin\Android.Support.v4\21.0.3 . I also tried C:\Users\MYUSER\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content shall I copy the folder "m2repository" or its content? – infinite_loop_ Aug 11 '15 at 14:05
  • @Mohamed Elrashid: False, for me this did NOT work! Don´t generalize too fast, Jason´s answer worked perfect for me – Best_Where_Gives Oct 23 '15 at 13:13
  • Hit this issue on OS X, and dig further into it, https://blog.lextudio.com/2016/05/android-support-repository-and-xamarin-android/ I personally think the error message itself is misleading. – Lex Li May 14 '16 at 11:46
  • As james says below. Delete all zips in "C:\Users\dev\AppData\Local\Xamarin\zips" and they will automatically download when you next build. – ComeIn Jul 14 '16 at 11:58
22

I'm just posting the Mohamed Elrashid's comment as an answer Because I think this is the best solution. Because it is in a comment and most of the people do not try this first.

You can DELETE everything in Corresponding the folder C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\ and Xamarin will automatically download again

It is valid for 22.2.1 version too, so I think it is a general solution of every version(guess)

EDIT => Please follow the ans by Jason that always works.

Suggestion: all these kind off error has a link for the zip to download and where to save it to fix. So for all other zip files follow the same ans.

loop
  • 9,002
  • 10
  • 40
  • 76
  • This answer should be marked as THE answer as it allows Xamarin toolchain to fix the problem with minimal manual actions. – Tok' Sep 03 '15 at 08:37
  • @Tok: False! It is not THE answer, for me THE answer was the one of Jason. It is FALSE that this answer solves it. I still got the errors (even more) after deleting the whole Dir – Best_Where_Gives Oct 23 '15 at 13:13
  • @Best_Where_Gives I also admit this, because the below answer always works for me too. So edit my answer here to save developers time. – loop Oct 23 '15 at 18:41
  • Just to note to new readers: try the method you wish (this one or below). This one always succeeds for me (several projects on several computers). Others have more success with the next (not with me btw...). – Tok' Jan 17 '16 at 23:02
  • http://bit.ly/23QpWim summarizes above PLUS I found the resolution to be the removing of a corrupt zip file – David Feb 07 '16 at 00:31
  • 1
    This solution worked for me. And this is preferred solution because it installs right components at right place. Thanks. – Omkara Apr 23 '16 at 08:06
9

It looks like the zip can get corrupted (I think I might have killed VS as I hadn't realised it was downloading a >100MB file).

If that's the case, just clear out the zip cache: C:\Users\dev\AppData\Local\Xamarin\zips and they'll all be re-downloaded.

JamesDill
  • 1,857
  • 1
  • 18
  • 22
  • 2
    Your analysis is correct, and I have written a blog post with more details, https://blog.lextudio.com/2016/05/android-support-repository-and-xamarin-android/ – Lex Li May 14 '16 at 11:44
  • This fixed me. I deleted all zips found in that location, and simply rebuilt my application. VS did the rest of the work. – John Livermore Jan 03 '17 at 21:14
  • 1
    This is the where the root case is. The location of the corrupt file or part file. clearing the directory's will also help but only if the file hear is not downloaded or corrupt. –  Feb 07 '17 at 07:27
6

This problem usually occurs because of failing to download or install m2repository file.

You can try one of these three options:

1- You can let VS solves the problem it self. It can be done just by deleting (...\AppData\Local\Xamarin\Android.Support.v4) directory and then rebuild the project. VS will download and install what it needs. If it does't work, go to number 2.

2- Manually Downloading android_m2repository_rnn.zip and putting it into (...\AppData\Local\Xamarin\zips ) folder. VS will do the rest (including extracting and installing the file). You can download m2repositories from here:

https://dl-ssl.google.com/android/repository/android_m2repository_r33.zip

Just rename the number at the end of URL to what you need and then download the file.

Note: In some cases you might need to rename the file into it's MD5 hash of URL. (for me VS was a little stupid and doesn't do anything unless I renamed the m2repository file to it's MD5 hash).

Here is a list of some of MD5 hashes:

android_m2repository_r33.zip --> 5FB756A25962361D17BBE99C3B3FCC44.zip android_m2repository_r32.zip --> F16A3455987DBAE5783F058F19F7FCDF.zip android_m2repository_r31.zip --> 99A8907CE2324316E754A95E4C2D786E.zip android_m2repository_r30.zip --> 05AD180B8BDC7C21D6BCB94DDE7F2C8F.zip android_m2repository_r29.zip --> 2A3A8A6D6826EF6CC653030E7D695C41.zip android_m2repository_r28.zip --> 17BE247580748F1EDB72E9F374AA0223.zip android_m2repository_r27.zip --> C9FD4FCD69D7D12B1D9DF076B7BE4E1C.zip android_m2repository_r26.zip --> 8157FC1C311BB36420C1D8992AF54A4D.zip android_m2repository_r25.zip --> 0B3F1796C97C707339FB13AE8507AF50.zip android_m2repository_r24.zip --> 8E3C9EC713781EDFE1EFBC5974136BEA.zip android_m2repository_r23.zip --> D5BB66B3640FD9B9C6362C9DB5AB0FE7.zip android_m2repository_r22.zip --> 96659D653BDE0FAEDB818170891F2BB0.zip android_m2repository_r21.zip --> CD3223F2EFE068A26682B9E9C4B6FBB5.zip android_m2repository_r20.zip --> 650E58DF02DB1A832386FA4A2DE46B1A.zip android_m2repository_r19.zip --> 263B062D6EFAA8AEE39E9460B8A5851A.zip android_m2repository_r18.zip --> 25947AD38DCB4865ABEB61522FAFDA0E.zip android_m2repository_r17.zip --> 49054774F44AE5F35A6BA9D3C117EFD8.zip android_m2repository_r16.zip --> 0595E577D19D31708195A83087881EE6.zip

You can also find the list here: https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/#Manually_Downloading_m2repository

3- Manually Downloading and Installing m2repository Files. The detailed process can be found here:

https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/#Manually_Downloading_and_Installing_m2repository_Files

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
1

Sometimes Android Studio will not download package because of network issues.

Here the solution for that.

Download zip package directly from https://dl-ssl.google.com/android/repository/android_m2repository_r22.zip

Delete existing package zip from C:\Users\josec\AppData\Local\Xamarin\zips and Put the downloaded package zip into it.

Cin
  • 113
  • 1
  • 8
1

I went through the same problem and I have just fixed using the following steps:

  • Delete the *.zip files from the folder:

C:\Users\YOUR_USER\AppData\Local\Xamarin\zips\

  • Delete the folders starting with "Xamarin.Android.*":

C:\Users\YOUR_USER\AppData\Local\Xamarin\Xamarin.Android.*

  • Navigate to the directory of your solution and delete all the "bin" and "obj" folders

  • Make sure you have the latest Java SDK. In my case the latest one is JDK 1.8:

C:\Program Files\Java\jdk1.8.0_111

  • In my case I didn't have the latest java SDK so I searched in google for "Java SE Development Kit Downloads". It took me to the Oracle website page about "Java SE Development Kit 8 Downloads". I downloaded the file "jdk-8u111-windows-x64.exe" (194.64 MB). After the installation it created a folder "C:\Program Files\Java\jdk*\".

  • Make sure your Xamarin is pointing to this JDK:

In the Visual Studio go to "Tools -> Options -> Xamarin -> Android Settings -> Java Development Kit". In my case I set it to "C:\Program Files\Java\jdk1.8.0_111"

  • Now you should right click in your solution and "Clear solution" and after that you should "Rebuild Solution"

I hope it helps.

0

Sometimes the download packages to fail:

  1. Download https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip OR Requst File
  2. Rename to 2A3A8A6D6826EF6CC653030E7D695C41.zip OR Requst File Name
  3. Copy to C:\Users\User\AppData\Local\Xamarin\zip
  4. Rebuild
Tunaki
  • 132,869
  • 46
  • 340
  • 423
0

1: Download "https://dl-ssl.google.com/android/repository/android_m2repository_r22.zip" into your (mediafire.com or other upload center websites)

2: Download "android_m2repository_r22.zip" from your mediafire panel into your computer

3: Rebuild your solution to get list of error codes

4: Find error(Error Reason: "C:\Users\Vahid\AppData\Local\Xamarin\zips\96659D653BDE0FAEDB818170891F2BB0.zip" is not a valid zip file)

5: Copy your android_m2repository_r22.zip into "C:\Users\Vahid\AppData\Local\Xamarin\zips\" directory

6: Rename "android_m2repository_r22.zip" to "96659D653BDE0FAEDB818170891F2BB0.zip"

7: Rebuild your solution

8: Enjoy xamarin form.

List of md5 name for your download file are available in "https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/#Manually_Downloading_m2repository"

Vahidshirzadi
  • 89
  • 1
  • 3
0

Please download and install https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\dev\AppData\Local\Xamarin\Android.Support.v4\21.0.3\content directory.

Adit Kothari
  • 63
  • 1
  • 10
  • This solution already posted by other user. Please post only if you have valuead or alternative solution – Raju Jul 14 '16 at 12:58
0

to rephrase the solution I did to solve such issue, I believe one of the 2 reasons below will cause such issue.

Broken/ incomplete downloaded zips This may have occurred because you cancelled or closed the VS out of frustration because it was taking too much time.

while in fact the visual studio is downloading the zips at AppData/Local/Xamarin/zips. because you closed visual studio, the zip files are not completely downloaded.

what you do is go to AppData/Local/Xamarin/zips delete all the zip files then AppData/Local/Xamarin you should only see Universal, zips and logs folders delete the rest. wait for the zips to install completely. this is gonna take time for sure.

Problem with the References Check if any of the references are showing any warning sign or something. if so remove the reference and reinstall it.

MohamedHamza
  • 205
  • 1
  • 12
0

In order to resolve this issue, I did following:

1) In my Xamarin.Forms project that was failing to build Android project, I removed all packages added by Xamarin.Forms package including Xamarin.forms package itself. In fact, I believe, you have to remove it first in order to remove others. Note you have to play bit to figure out which one will remove until you can remove its dependants. Simple thing to do!

2) Exit Xamarin Studio

3) I then went to my /Users/user_name/.local/share/Xamarin/Xamarin.Android.Support.v4/23.3.0.0/ directory and deleted whole zip folder and all Xamarin.Android.* folders (* is wild card for anyting)

4) Start Xamarin Studio

5) Delete all bin and obj directories in all projects of your solution (in my case Android, IOS and Xamarin.Forms projects)

6) Right click on Packages in your Android project, Add Package..., search for Xamarin.Forms and add it. This will add bunch of other dependant packages. In my case, following were added:

  • Xamarin.Android.Support.Animated.Vector.Drawable
    • Xamarin.Android.Support.Design
    • Xamarin.Android.Support.v4
    • Xamarin.Android.Support.v7.AppCompat
    • Xamarin.Android.Support.v7.CardView
    • Xamarin.Android.Support.v7.MediaRouter
    • Xamarin.Android.Support.v7.RecyclerView
    • Xamarin.Android.Support.Vector.Drawable
    • Xamarin.Forms

7) Clean All

8) Rebuild All

Before this, I was getting about 20 errors no matter what I try, all of them relating to Android.Support.Library.v4 and number of files missing in mine /Users/user_name/.local/share/Xamarin/Xamarin.Android.Support.v4/23.3.0.0/content and /Users/user_name/.local/share/Xamarin/Xamarin.Android.Support.v4/23.3.0.0/embedded directories. The error was along the lines "Please install package: 'Android Support Library' available in SDK installer."

pixel
  • 9,653
  • 16
  • 82
  • 149
0

If you are from Iran or other countries which are blocked by google, you will get these kinda errors because Xamarin can't dl the packages from google. in that case Please try deleting the zips folder, and any Android.Support.* folders from inside C:\Users\username\AppData\Local\Xamarin then try rebuild the android project after connecting to a VPN like https://www.betternet.co/.

fire in the hole
  • 1,171
  • 15
  • 34
0

Delete all foldeC:\Users[username]\AppData\Local\Xamarin. And then rebuild your project.

Hope this help

RPD
  • 1
  • 3