Reputation: 23
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:\Dev\XamTest\XamTest\XamTest.Android\Resources\values\styles.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
\Dev\XamTest\XamTest\XamTest.Android\obj\Debug\resourcecache\96A6E7245B001AFA9465D8F3C01B0DCD\res\layout\notification_template_big_media.xml:42: error: No resource identifier found for attribute 'layoutDirection' in package 'android' XamTest.Android C:\Dev\XamTest\XamTest\XamTest.Android\C
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.
Upvotes: 2
Views: 782
Reputation: 74094
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
General
setting, set the target framework:Use Latest installed platform (8.1)
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.
Upvotes: 4