Xamarin 为 android 4 创建应用程序 (VS2017 15.5.5) [英] Xamarin create application for android 4 (VS2017 15.5.5)

查看:41
本文介绍了Xamarin 为 android 4 创建应用程序 (VS2017 15.5.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 xamarin (VS 2017 15.5.5) 创建一个 android 应用程序.默认设置(xamarin 跨平台-空白应用/.net 标准,针对android 7)生成可以通过live player 部署的项目,但是构建过程会产生错误

im trying to create an android application with xamarin (VS 2017 15.5.5). The default settings (xamarin cross-platform - blank app / .net standard, targeting android 7) generates project that can be deployed via live player, but the build process generates error

Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'XamTest, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'XamTest.dll'
....
....

我的目标是为 android 4 (4.0.3/4.1) 及更高版本创建 android 应用程序,但更改项目属性中的设置(目标框架 + 最低版本 + 目标 android 版本.全部设置为 4.1)会导致 15此类错误:

My goal is to create android application for android 4 (4.0.3 / 4.1) and higher, but changing the settings (target framework + min. version + target android ver. all set to 4.1) in project properties results in 15 errors of these kind:

Error: NU1202 Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 is not compatible with monoandroid41 (MonoAndroid,Version=v4.1). Package Xamarin.Android.Support.v7.MediaRouter 25.4.0.2 supports: monoandroid70 (MonoAndroid,Version=v7.0)               
Error: No resource found that matches the given name: attr 'colorAccent'.   XamTest.Android C:DevXamTestXamTestXamTest.AndroidResourcesvaluesstyles.xml

所以我删除了 NuGet 包管理器中的所有支持库、一些未定义的样式和两个预生成的 xaml 文件(工具栏、任务栏).现在我有 38 个这种类型的错误

So i deleted all support libraries in NuGet package manager, some undefined styles and two pre-generated xaml files (Toolbar, Taskbar). Now i have 38 errors of this type

DevXamTestXamTestXamTest.AndroidobjDebug
esourcecache96A6E7245B001AFA9465D8F3C01B0DCD
eslayout
otification_template_big_media.xml:42: error: No resource identifier found for attribute 'layoutDirection' in package 'android'   XamTest.Android C:DevXamTestXamTestXamTest.AndroidC        

还有一个错误

Error NU1202 Package Xamarin.Android.Support.Design 23.3.0 is not compatible with monoandroid41 (MonoAndroid,Version=v4.1). Package Xamarin.Android.Support.Design 23.3.0 supports: monoandroid43 (MonoAndroid,Version=v4.3)                

没有链接支持库(只有 xamarin.forms)所以我不明白 Suppurt.Design 来自哪里......

No support library is linked (only xamarin.forms) so i dont understand where Suppurt.Design comes from...

我花了两天时间研究、阅读文档、教程等,但我还没有找到任何合适的答案.那么,有没有什么简单的方法可以设置一个针对 Android 4.1 的 Android 项目呢?

I have spent two days with sdudying, reading doc, tutorials etc. but i havent found any suitable answer. So, is there any simple way how to set up an Android project targeting Android 4.1?

谢谢.

推荐答案

最新版本的 Forms 需要针对 Android 8.0(至少)编译.为了针对 API 级别 15编译,您需要使用非常旧版本的表单.

The latest version of Forms needs to compile against Android 8.0 (at least). In order to compile against API level 15, you would need to use a very old version of Forms.

相反,针对最新的 API 进行编译并设置您的 min.并将 API 级别目标为 4.0.3

Instead, compile against the latest API and set your min. and target APIs levels to 4.0.3

  • 目标框架:使用最新安装的平台(8.1)
  • 最低 Android 版本:覆盖 - Android 4.0.3(API 级别 15)

目标 Android 版本:覆盖 - Android 4.0.3(API 级别 15)

Target Android version: Override - Android 4.0.3 (API level 15)

这会生成一个清单,其中包括:

This results in a manifest that includes:

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="15" />

注意:您需要针对 Android 4.0.3 设备/模拟器进行测试,以确保您没有使用来自更高版本的 Android SDK 的 API.

Note: You will need to test against an Android 4.0.3 device/emualtor to ensure that you are not using APIs from later versions of the Android SDK.

这篇关于Xamarin 为 android 4 创建应用程序 (VS2017 15.5.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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