0
votes

I've created a blank Mobile App (Xamarin.Forms) application.

enter image description here

By default the target Android framework for this empty application is set to version 8.1 (Oreo)

enter image description here

I want to change this version to version 8.0, which is installed and available on the workstation.

enter image description here

But when I select the version 8.0 and Visual Studio recompiles the project I get a bunch of errors.

enter image description here

Error NU1202 Package Xamarin.Android.Support.Design 27.0.2.1 is not compatible with monoandroid80 (MonoAndroid,Version=v8.0). Package Xamarin.Android.Support.Design 27.0.2.1 supports: monoandroid81 (MonoAndroid,Version=v8.1)

Okay, then. I opened NuGet Manager and tried to update (downgrade) versions of corresponding components.

enter image description here

But when I try to reinstall a component with a lower version over an existing higher version I get the same error messages. And I get these messages for every component I want to downgrade.

The question: how can I change the target framework version for Android Xamarin application and it will finally work?


UPDATE

I tried to remove MonoAndroid reference from the Android Xamarin project in the Solution and add the reference to the lower version manually.

enter image description here

But as I click OK on the dialog, the MonoAndroid reference version 8 (instead of version 7) has been added.

enter image description here

1
You need to replace MonoAndroid with version 7.x, somehow.TheWanderer
@TheWanderer thank you, but how can I do this replacement? I supposed (probably I am a naive person) that a full fledged IDE like VS will do it as I change target Android API version. But I was wrong. I searched on StackOverflow, but posts like this unfortunately do not help.Novice Student
I wish I knew. I've never even used VS, much less Xamarin.TheWanderer
@TheWanderer anyway thanks. I have updated my question with the pictures. I tried to remove the reference to the MonoAndroid and replace it with the reference to the lower version. But it did not work. Visual Studio adds another version than I selected manually.Novice Student
To whoever silently downvotes my question, what is wrong with my question?Novice Student

1 Answers

1
votes

If you really need to use 8.0 instead of 8.1, then you will need to remove all of the 27.x.x versions of the Xamarin.Android.Support packages and install the 26.1.0.1 versions instead as the 27.x.x series is not compatible with Android version < 8.1.

But why do you need to target/compile with Android 8.0? Generally you want to compile with and target the latest available version. You can then set the minimum android version you want to support in the Android Manifest "Minimum Android Version" property in the project properties. Or this entry in the raw XML for the manifest:

<uses-sdk android:minSdkVersion="21" /> 

where "21" is the API number for the minimum version you want to support. Just make sure you do not use any types/methods/etc that are only available in Android versions > the minimum version you set. If you do that, your app will run on all Android versions >= the minimum version set. So perhaps you only need to set the minimum version and not the "Compile with ..." and/or "Target" android version?