本文介绍了即使在 Xamarin 中安装 android v4 支持库后也会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使从 Xamarin Component Store 安装 v4 支持库后,我还是收到此错误.我尝试使用谷歌搜索这些问题,但在开发 android 应用程序时,我总是在 Xamarin Studio 中遇到相同的错误

Even after installing v4 support library from Xamarin Component Store,I get this error.I tried googling for these problems but I always get the same error in Xamarin Studio while developing android app

推荐答案

This is Xamarin Bug32498

当您正常安装 Xamarin.Android.Support.* nuget 包之一时,问题就开始了.

The problem starts when you are normally installing one of Xamarin.Android.Support.* nuget packages.

然后 IDE(对我来说是 VS2015)挂起并且没有任何进展,因此您被迫关闭 IDE.重新打开 IDE 并强制链接到程序集以及构建项目时,它说:

Then IDE (VS2015 for me) hangs and nothing goes well, so you're forced to shutdown the IDE. After re-openning the IDE and forcing a link to the assemblies and when it comes to build the project, it says :

包 android.support.* 不存在

这是后台发生的事情:

首先你必须知道:

Xamarin.Android.Support.* 实际上是 google 支持库 的 C# 绑定(用 JAVA 编写),因此它们不是完全本机的,它们封装了谷歌支持库(有关 Xamarin C# 绑定的更多信息,请阅读:Binding AJava 库).

Xamarin.Android.Support.* are actually C# bindings of google support libraries (THAT ARE WRITTEN IN JAVA), so they are not completely native and they wrappers of google support libraries (for more about Xamarin C# bindings read : Binding A Java Library).

错误场景:

IDE 挂起的时间是它开始从 ,用于每个 Xamarin.Android.Support.* 包,然后将其解压缩到

The time the IDE hangs is the time when it starts downloading Google Support Library Sources (about 96 MB) from the internet for each of the Xamarin.Android.Support.* packages then extracting it to

C:Users\%username%AppDataLocalXamarin

解决方案:

我提出了两种解决方案:

Solutions:

I propose 2 solutions:

  1. 朋友告诉我用22.2.1以外的版本可以解决问题(我没试过)

  1. A friend told me that using a version other than 22.2.1 would solve the problem ( I didn't try it)

手动提取包(例如 Xamarin.Android.Support.v4):

Manual Extracting of the package (e.g. Xamarin.Android.Support.v4):

  1. 转到C:Users\%username%AppDataLocalXamarin,删除具有所需库名称的文件夹(如果存在),例如Android.Support.v4
  2. 使用所需的库名称创建路径 C:Users\%username%AppDataLocalXamarin{LibraryName}22.2.1 例如C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.1
  3. 此处 (v16) 下载 Google 支持库源.
  4. 复制并解压到C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.10content
  5. 打开预先下载的存档 android_m2repository_r16,导航到 m2repositorycomandroidsupport 并转到 libraryname22.2.1code>(例如 support-v422.2.1.搜索并打开 libraryName-22.2.1.aar(例如 support-v4-22.2.1.aar(直接用WinRAR打开)将文件内容解压到C:Users\%username%AppDataLocalXamarin{LibraryName}22.2.10embedded例如 C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.10embedded

  1. Go to C:Users\%username%AppDataLocalXamarin, delete the folder with the desired library name if it exists e.g. Android.Support.v4
  2. Create a path with the desired library name C:Users\%username%AppDataLocalXamarin{LibraryName}22.2.1 e.g. C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.1
  3. Download Google Support Library Source from here (v16).
  4. Copy it and extract its content into C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.10content
  5. Open the pre-downloaded archive android_m2repository_r16, navigate to m2repositorycomandroidsupport and go to libraryname22.2.1 (e.g. support-v422.2.1. Search for and open libraryName-22.2.1.aar (e.g. support-v4-22.2.1.aar (it opens directly with WinRAR) extract the content of the file to C:Users\%username%AppDataLocalXamarin{LibraryName}22.2.10embedded e.g. C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.10embedded

运行包安装nuget命令

Run the package installation nuget command

编辑

你必须在 C:Users\%username%AppDataLocalXamarinAndroid.Support.v422.2.10

这篇关于即使在 Xamarin 中安装 android v4 支持库后也会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:31