Build unsuccessful : Error with Android project in Xamarin.Forms

后端 未结 6 1393
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 06:45

I just create a small Xamarin.Forms sample application. When i build my Android project i get some errors. I just googled errors and find some solutions. But nothing works f

相关标签:
6条回答
  • 2020-12-06 07:33

    Delete the zip at \Local\Xamarin\zips\1FD832DCC1792D8ACA07FAC3259FC5A9.zip

    Clean and Rebuild your solution.

    0 讨论(0)
  • 2020-12-06 07:35

    Spent a whole night struggling to get this working, turned out i had forcefully shut down VS during an initial build thinking it got stuck not knowing it was actually downloading a > 200MB file to my C:\Users[UserName]\AppData\Local\Xamarin\zips folder.

    Deleting the corrupt zip file and being patient enough to rerun a rebuild definitely fixed the issue.

    0 讨论(0)
  • 2020-12-06 07:41

    Delete all the zip files. Even if it asks you to download and replace, it will corrupt again. The quicker way is to just delete all the zip files and rebuild, it will automatically download and unzip as required.

    The Android m2repository gets corrupted often on my machine.

    With Android I also suggest, build against API 23 (6.0) and set you minimum level to 15 (unless you really need API 10). Make sure you don't use the "Latest SDK" selection, that has been known to cause issues in the past as well, select the highest API beneath that.

    0 讨论(0)
  • 2020-12-06 07:42

    EDIT: This information is now included in our documentation: https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/

    Xamarin.Android Support Library NuGet m2repository fixes

    1. Investigation

    You may run into issues with downloading the m2repository when referencing a NuGet package of the Android Support Libraries / Google Play Services.

    Example error:

    Download failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r25.zip and put it to the C:\Users\[Username]\AppData\Local\Xamarin\{SUPPORT LIBRARY NAME}\{VERSION NUMBER} directory."

    Mac Directory: /Users/[Username]/.local/share/Xamarin/

    Windows Directory: C:\Users\[Username]\AppData\Local\Xamarin\

    2. Folder Contents

    This example will be using Windows paths. This can be applied to either OS.

    • Given the following: C:\Users\[Username]\AppData\Local\Xamarin\

    • A folder for each of the respective Android Support Libraries / Google Play Services will be shown.

    • Each library should have a collection of versions:

    Note: In this example I'm showing all of the versions of Android.Support.v4

    • We will then investigate the respective version we're interested in. We should see two folders inside, content and embedded:

    1. content - Contains the m2repository
    2. embedded - Contains the respective .aar contents

    3. Automatic Fix

    • Delete the versioned library folder that is giving you errors:

    Mac Directory: /Users/[Username]/.local/share/Xamarin/{SUPPORT LIBRARY NAME}/{VERSION NUMBER}

    Windows Directory: C:\Users\[Username]\AppData\Local\Xamarin\{SUPPORT LIBRARY NAME}\{VERSION NUMBER}

    • Rebuild your project (Which will kickoff a Build Task to re-download the library).

    4. Manual Fix

    There are two steps to manually fixing this error.

    1. Adding the m2repository folder to the /content folder.
    2. Adding the respective Android Support Library / Google Play Services .aar contents to the /embedded folder.
    1. Adding the m2repository to the /content folder

    Download the respective m2repository from google.

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

    Note: This version number will vary based on your error message.

    • Extract that .zip to any directory. There should now be a android_m2repository_r25 folder.
    • Inside the android_m2repository_r25 folder, we have a m2repository folder.
    • Place the m2repository into the {VERSION NUMBER}/content folder

    2. Adding the .aar contents to the /embedded folder
    • Inside the m2repository folder, there is an .aar for the support library to be resolved. It can be found in the com\android\support directory:

    Example:

    m2repository\com\android\support

    • There should be a support-v4\{VERSION NUMBER} which will contain the .aar file.
    • Extract the .aar and put the contents into the embedded folder.

    Example:

    • m2repository\com\android\support\support-v4\23.1.1\support-v4-23.1.1 will contain items such as a aapt, aidl, assets, libs, res, AndroidManifest.xml, annotations.zip, and classes.jar.
    • Place all of the contents into the {VERSION NUMBER}/embedded folder.

    5. New Manual Fix

    • Get the URL of the missing m2repository download
    • Use a MD5 hash on the download URL
    • Rename the file to {MD5HASH}.zip (Where MD5HASH is the hashed download URL)
    • Place the new hashed .zip file in your Xamarin\zips directory
    0 讨论(0)
  • 2020-12-06 07:42

    In Simple Words

    -> After handling and clearing all the Errors in your Xml documents

    -> click on the hammer icon to build and make project Or Press Ctrl+F9

    0 讨论(0)
  • 2020-12-06 07:49

    I get that problem when tried to use xamarin forms 2.0

    The problem usually comes when IDE (VS2015 for example) try to decompress that zip... VS hangs and you must force close it ... when you reopen the IDE you cannot compile anything with xamarin that use this version.

    First of all you should download r23 no r10. Each one contains assemblies for each version api.

    When you have it you should delete library folder on C:\Users\%username%\AppData\Local\Xamarin for example Android.Support.v4

    Create a path with the library name C:\Users\%username%\AppData\Local\Xamarin{LibraryName}\23.0.1

    Copy and unzip download r23 to C:\Users\%username%\AppData\Local\Xamarin\Android.Support.v4\22.2.10\content

    Go to m2repository\com\android\support and under libraryname\version you will get a file with extension ".aar" this is a zip file rename to .rar and unzip it to C:\Users\%username%\AppData\Local\Xamarin{LibraryName}\23.0.1\embedded

    By the way a copy of downloaded r23.zip must be leaved on:

    C:\Users\%username%\AppData\Local\Xamarin{library name}\23.0.1\

    When you have done this you are able to compile again

    0 讨论(0)
提交回复
热议问题