构建失败:Xamarin.Forms 中的 Android 项目出错 [英] Build unsuccessful : Error with Android project in Xamarin.Forms

查看:21
本文介绍了构建失败:Xamarin.Forms 中的 Android 项目出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是创建了一个小的 Xamarin.Forms 示例应用程序.当我构建我的 Android 项目时,我遇到了一些错误.我只是在谷歌上搜索错误并找到了一些解决方案.但没有任何工作正常.最后一天我重新安装了 Visual Studio 2015 和 Xamarin Studio.所以 xamarin 可能会全部更新.

这里我只列出我的错误和建议的解决方案.

<小时>

错误 1:

解压失败.请下载

注意:此版本号会根据您的错误消息而有所不同.

  • 将该 .zip 解压缩到任何目录.现在应该有一个 android_m2repository_r25 文件夹.
  • android_m2repository_r25 文件夹内,我们有一个 m2repository 文件夹.
  • m2repository 放入 {VERSION NUMBER}/content 文件夹

2.将.aar内容添加到/embedded文件夹
  • m2repository 文件夹内,有一个.aar 用于要解析的支持库.可以在comandroidsupport目录下找到:

示例:

m2repositorycomandroidsupport

  • 应该有一个 support-v4{VERSION NUMBER} 将包含 .aar 文件.
  • 解压.aar并将内容放入embedded文件夹.

示例:

  • m2repositorycomandroidsupportsupport-v423.1.1support-v4-23.1.1 将包含诸如 aaptaidlassetslibsresAndroidManifest.xml注解.zipclasses.jar.
  • 将所有内容放入 {VERSION NUMBER}/embedded 文件夹.

5.新的手动修复

  • 获取丢失的 m2repository 下载地址
  • 在下载 URL 上使用 MD5 哈希
  • 将文件重命名为 {MD5HASH}.zip(其中 MD5HASH 是经过哈希处理的下载 URL)
  • 将新的散列 .zip 文件放在 Xamarinzips 目录中

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 fine. Last day i had reinstalled Visual Studio 2015 and Xamarin Studio. So probably xamarin will be updated in all.

Here I just list my errors and suggested solutions.


Error 1 :

Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the ...~LocalXamarinAndroid.Support.v421.0.3content directory.

Suggested solution : The file is downloaded successfully and replaced as per the error message.


Error 2 : _Please install package: 'Android Support Library' available in SDK installer. Java library file ...~LocalXamarinAndroid.Support.v421.0.3embeddedclasses.jar doesn't exist. Please install package: 'Android Support Library' available in SDK installer. Java library file ...~LocalXamarinAndroid.Support.v421.0.3embeddedlibs/internal_impl-21.0.3.jar doesn't exist._

Suggested solution : Android Support Library is deleted and reinstalled.


Error 3 : Reason: ...~LocalXamarinzips1FD832DCC1792D8ACA07FAC3259FC5A9.zip is not a valid zip file.

Suggested solution : I didn't find any solutions for this error.


These solutions are still useless. and not working in my case.


I'm using :

  • Xamarin 4.0.0.1689 (f860fe4)
  • Xamarin.Android 6.0.0.34 (3efa14c)
  • Xamarin.iOS 9.2.1.51 (3c0ec35)

Here is the detailed report :

=== Xamarin Studio ===

Version 5.10 (build 871) Installation UUID: c5309e12-1ab1-494c-9296-033a0a5c3f24 Runtime: Microsoft .NET 4.0.30319.42000 GTK+ 2.24.23 (MS-Windows theme) GTK# 2.12.30

=== Xamarin.Android ===

Version: 6.0.0 Android SDK: D:Androidandroid-sdk Supported Android versions: 2.3 (API level 10) 4.0.3 (API level 15) 4.1 (API level 16) 4.2 (API level 17) 4.3 (API level 18) 4.4 (API level 19) 4.4.87 (API level 20) 5.0 (API level 21) 5.1 (API level 22) 6.0 (API level 23)

SDK Tools Version: 24.4

SDK Platform Tools Version: 23.0.1

SDK Build Tools Version: 23.0.1

Java SDK: C:Program Files (x86)Javajdk1.7.0_55 java version "1.7.0_55" Java(TM) SE Runtime Environment (build 1.7.0_55-b13) Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)

=== Xamarin Android Player ===

Version: 0.6.5 Location: C:Program FilesXamarin Android PlayerDeviceManager.exe

=== Build Information ===

Release ID: 510000871 Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88 Build date: 2015-11-12 07:16:34-05 Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8 Build lane: monodevelop-windows-cycle6

=== Operating System ===

Windows 6.3.9600.0 (64-bit)

Any ideas or suggestions to come out of this errors ?

解决方案

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]AppDataLocalXamarin{SUPPORT LIBRARY NAME}{VERSION NUMBER} directory."

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

Windows Directory: C:Users[Username]AppDataLocalXamarin

2. Folder Contents

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

  • Given the following: C:Users[Username]AppDataLocalXamarin

  • 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]AppDataLocalXamarin{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 comandroidsupport directory:

Example:

m2repositorycomandroidsupport

  • 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:

  • m2repositorycomandroidsupportsupport-v423.1.1support-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 Xamarinzips directory

这篇关于构建失败:Xamarin.Forms 中的 Android 项目出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆