Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
509 views
in Technique[技术] by (71.8m points)

xamarin.forms - Xamarin create application for android 4 (VS2017 15.5.5)

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'
....
....

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

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        

and one error

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)                

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

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?

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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

Under General setting, set the target framework:

  • Target framework: Use Latest installed platform (8.1)

Under Android Application:

  • Min Android version: Override - Android 4.0.3 (API level 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" />

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...