android studio v4支持库,Visual Studio 2015 - 添加Android支持库v4和v7以使用DrawerLayout和ActionBarDrawerToggle(Vis...

Visual Studio 2015 - 添加Android支持库v4和v7以使用DrawerLayout和ActionBarDrawerToggle(Visual Studio 2015 - Adding Android Support Library v4 and v7 to use DrawerLayout and ActionBarDrawerToggle)

我试图通过Visual Studio中的Nuget Manager将这两个支持库添加到我的项目中,以便能够使用DrawerLayout和ActionBarDrawerToggle 。 但是,两个库都无法以相同的错误进行安装:

*****无法安装包'Xamarin.Android.Support.Compat 24.2.1'。 您正在尝试将此软件包安装到以“.NETFramework,Version = v4.5”为目标的项目中,但该软件包不包含任何与该框架兼容的程序集引用或内容文件。 有关更多信息,请与软件包作者联系。*****(错误的屏幕截图也在底部提供)

以下是VS2015 Nuget Package Manager中显示的这两个库的屏幕截图:

Xamarin.Android.Support.v4

9d5xQ.png

Xamarin.Android.Support.v7.AppCompat v 24.2.1

4e6236273737cd9b8000853cd3a81db1.png

我已经在我的Android SDK Manager中安装了从API19到API25的SDK平台,在Extras中,我有Android支持存储库和Android支持库,如下所示: 7c4af68c0d39860694e0704242919852.png

我已经安装了从19到25.2.2的Android SDK工具,平台工具和构建工具:

4524bf8b27041225b8fc249cba1477ce.png

一旦我选择将这两个库安装到我的项目并在Review Changes对话框和License Acceptance对话框中点击OK,安装就会失败,如下所示:

6d5eab36d9a04a04129abb675386836e.png

I am trying to add these 2 support libraries to my project through Nuget Manager in Visual Studio in order to be able to use DrawerLayout and ActionBarDrawerToggle. However, both libraries are failing to install with the same error:

*****Could not install package 'Xamarin.Android.Support.Compat 24.2.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.***** (the screenshot of the error is also provided at the bottom)

Below are screenshots for these 2 libraries as shown in VS2015 Nuget Package Manager:

Xamarin.Android.Support.v4

07b838dc255ffafcf35321a1ea1ae71b.png

Xamarin.Android.Support.v7.AppCompat v 24.2.1

4e6236273737cd9b8000853cd3a81db1.png

I have installed SDK Platforms in my Android SDK Manager from API19 to API25 and in Extras, I have both Android Support Repository and Android Support Library as can be seen below: 7c4af68c0d39860694e0704242919852.png

And I have installed Android SDK Tools, Platform-tools and Build-tools from 19 to 25.2.2:

4524bf8b27041225b8fc249cba1477ce.png

Once I select to install these 2 libraries to my project and hit OK on Review Changes dialog and Licence Acceptance dialog, the installation fails with error like below:

6d5eab36d9a04a04129abb675386836e.png

原文:https://stackoverflow.com/questions/40471416

更新时间:2020-02-21 22:56

最满意答案

Xamarin.Android.Support.Compat 24.2.1 NuGet包中包含MonoAndroid v7.0的程序集。 因此,您需要将Android项目的目标框架更改为7.0。 您应该能够在Visual Studio项目选项中更改它。

如果v7.0不可用,您可能需要更新Android SDK。

It appears that all I needed to do is to restart my Visual Studio.

2016-11-07

相关问答

v7包含v4支持库,因此不需要再次将其放在那里 如果您查看v7支持库的libs文件夹,您将看到v4 jar已经在库中被引用 v7 includes the v4 support library so there is no need to have it in there again if you look in the libs folder of the v7 support library you will see that the v4 jar is already referenced

...

我建议将您的Xamarin.Android版本和当前的dll升级到新的“Xamarin”版本。 EX:

Components\xamandroidsupportv7appcompat-7.18.0\lib\android\Xamarin.Android.Support.v4.dll

您可以通过右键单击components文件夹并

...

我通过导入较新的android.support.v7.app.ActionBarDrawerToggle和使用RecyclerView而不是ListView来解决我的问题,如下例所示: 如何使用Header View制作Material Design Navigation Drawer : private ActionBarDrawerToggle mDrawerToggle;

//... ...

mDrawerToggle = new ActionBarDrawerToggle(

...

我能够下载这个软件包并使其无需更改即可运行。 你恢复了nuget包吗? 此外,您可能希望在还原软件包后对解决方案进行全面清理和重建。 我在博客中介绍了使用设计支持库实现导航抽屉的更新方法: https : //blog.xamarin.com/add-beautiful-material-design-with-the-android-support-design-library/ 我还有一个GitHub仓库,里面有你想看的导航抽屉样本: https : //github.com/jamesmon

...

仅将android-support-v7-appcompat.jar到库依赖关系是不够的,您还可以在项目中导入可以在SDK中的路径\android-sdk\extras\android\support\v7\appcompat找到的模块\android-sdk\extras\android\support\v7\appcompat ,之后添加模块依赖关系以这种方式配置项目结构 否则仅包括支持库的类文件,并且应用程序无法加载导致错误的其他资源。 另外reverse建议替换这个 public Cust

...

它应该通过添加NuGet包来工作。 一些事情要检查。 如果您位于Windows文件系统上,找不到的文件的完整路径长度不能超过255个字符 删除NuGet包并尝试再次添加它,看看是否有帮助 确保你拥有所有工具的最新稳定版本 确保您的Android SDK安装中一切正常 It should just work by adding the NuGet package. A couple of things to check. The full path to the files it cannot fi

...

Xamarin.Android.Support.Compat 24.2.1 NuGet包中包含MonoAndroid v7.0的程序集。 因此,您需要将Android项目的目标框架更改为7.0。 您应该能够在Visual Studio项目选项中更改它。 如果v7.0不可用,您可能需要更新Android SDK。 另见此论坛帖子 。 It appears that all I needed to do is to restart my Visual Studio.

您必须删除此行compile files('libs/android-support-v4.jar') ,您必须删除此文件。 只能通过gradle添加支持库。 你已经在这行compile 'com.android.support:support-v4:20.0.+' 。 你的targetSdkVersion和你的compileSdkVersion也很奇怪。 L开发人员预览不支持这些值。 compileSdkversion应为'android-L' , targetSdkVersion应为'L' 。

...

我在TeamCity nuget feed中遇到了类似的问题。 回答你的第一个问题,是的,我相信VS2015仍然支持Nuget API V1。 到目前为止,我认为这是我所知道的: TeamCity可以使用Nuget API的v1或v2。 FindPackagesById在Nuget API v2而不是v1中实现(您可以通过在TeamCity Data目录中的internal.properties文件中添加一行teamcity.nuget.api.version=v2来强制TeamCity使用v2。

...

如果您使用Nuget Package Manager您可以这样做: PM> Install-Package Xamarin.Android.Support.Design

查看文档的更多详细信息 对于Android Support Library v4您可以这样做: PM> Install-Package Xamarin.Android.Support.v4

查看有关文档的更多信息 另外看看这个“BUG” If you use Nuget Package Manager you can do i

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值