问题描述
我有一个带有Prism MVVM的Xamarin.Forms,在Visual Studio 2017 15.7.2中有构建问题.
I have a Xamarin.Forms with Prism MVVM, having build problem in Visual Studio 2017 15.7.2.
该项目是在Visual Studio 2017 15.6.2中使用Prism模板创建的,并且运行良好.
This project was created in Visual Studio 2017 15.6.2, with Prism template, and was working perfectly.
我决定将IDE从15.6.2更新到15.7.2,并且我的项目停止工作,并出现以下错误:
I decided to update my IDE from 15.6.2 to 15.7.2, and my project stops working, getting the error below:
Severity Code Description Project File Line Suppression State
Error Your project is not referencing the "MonoAndroid,Version=v8.1" framework. Add a reference to "MonoAndroid,Version=v8.1" in the "frameworks" section of your project.json, and then re-run NuGet restore. AppPrivateCard.Android
A Xamarin.Forms project do not have project.json file, as suggested by the error message, and I already modified the target Android version to Android 27 version (Android Oreo 8.1), but the error persists.
我已经将Xamarin.Forms更新为3.0.0.482510,什么也没有.
I have already update Xamarin.Forms to 3.0.0.482510 and nothing.
但是,如果我使用VS 2017 15.7.2创建了一个没有Prism的Xamarin项目并更新了所有引用,那么它的构建就不会出现此错误.所以,我认为问题是棱镜模板.
But, if I create a Xamarin project without Prism, using VS 2017 15.7.2, and update all references, it builds without this error. So, I think the problem is the Prism template.
对我来说,一个选项是降级VS 2017,但我宁愿不降级.
One option for me is to downgrade the VS 2017, but I would rather not.
推荐答案
我有同样的问题.
原因:当我的项目目标是android版本8.1时,文件obj/project.assets.json目标"MonoAndroid,Version = v7.1"
Reason: file obj/project.assets.json target "MonoAndroid,Version=v7.1" when my project target android version 8.1
我通过以下方式解决了该问题:
I resolved it by:
- 右键单击Android项目=>属性=>应用程序=>编译使用Android版本=> Android 7.1
- 清理并生成项目=>生成成功,然后重新启动IDE.
- 右键单击Android项目=>属性=>应用程序=>编译使用Android版本=> Android 8.1
- 清理并构建项目=>构建成功
- Right click Android project => Properties => Application => Compileusing Android version => Android 7.1
- Clean and Build project => build success, and restart IDE.
- Right click Android project => Properties => Application => Compileusing Android version => Android 8.1
- Clean and Build project => build success
文件obj/project.assets.json已更新为"MonoAndroid,Version = v8.1"
File obj/project.assets.json updated to "MonoAndroid,Version=v8.1"
这篇关于无法在Visual Studio 2017 15.7.2中构建带有Prism的Xamarin.Forms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!