xamarin / AndroidSupportComponents

Xamarin bindings for Android Support libraries - For AndroidX see https://github.com/xamarin/AndroidX
MIT License
146 stars 56 forks source link

Can't install Xamarin.Android.Support.Compat 24.2.1 #21

Closed MihaMarkic closed 8 years ago

MihaMarkic commented 8 years ago

Xamarin.Android Version (eg: 6.0):

7.0.1.3

Operating System & Version (eg: Mac OSX 10.11):

Win 10 Anniversary

Support Libraries Version (eg: 23.3.0):

24.2.1

Describe your Issue:

When adding the NuGet package I get this: ... Attempting to resolve dependencies for package 'Xamarin.Android.Support.Compat.24.2.1' with DependencyBehavior 'Lowest' Resolving dependency information took 0 ms Resolving actions to install package 'Xamarin.Android.Support.Compat.24.2.1' Resolved actions to install package 'Xamarin.Android.Support.Compat.24.2.1' Retrieving package 'Xamarin.Android.Support.Compat 24.2.1' from 'nuget.org'. For adding package 'Xamarin.Android.Support.Compat.24.2.1' to project 'MYPROJECT' that targets 'monoandroid60'. Install failed. Rolling back... Package 'Xamarin.Android.Support.Compat.24.2.1' does not exist in project 'MYPROJECT' Package 'Xamarin.Android.Support.Compat.24.2.1' does not exist in folder 'D:\PATH\MYPROJECT\packages' Executing nuget actions took 6 ms Could not install package 'Xamarin.Android.Support.Compat 24.2.1'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Steps to Reproduce (with link to sample solution if possible):

Create a new blank android project, target: Compile: 5.1, Min: 4.1, Target: 4.1

Redth commented 8 years ago

Your app needs to have its Target Framework set to Android 7.0 (API Level 24) or higher to install these.

MihaMarkic commented 8 years ago

What is the reasoning behind this? AppCompat depends on it and it won't install as well. So either I use an older AppCompat or target 7.0. Perhaps you can drop a note in Readme at least.

Redth commented 8 years ago

We are following Google's recommendations now, which is you should always use the same API Level # as the Major version # for the Support Libraries you reference (so, API Level 24, you can use Support 24.2.1, API Level 23 should use Support 23.x, etc). In fact, if you try and mix and match in Android Studio, gradle will give you an error telling you they are mismatched.

Really, you should always try and compile against the latest SDK level. Here's a great article on picking your minSdkVersion, targetSdkVersion, and compileSdkVersion (same as our Target Framework). https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd#.6sw1nhe2h

Here's a relevant quote from the article:

Note that if you use the Support Library, compiling with the latest SDK is a requirement for using the latest Support Library releases. For example, to use the 23.1.1 Support Library, you must have a compileSdkVersion of at least 23 (those first numbers need to match!). In general, a new version of the Support Library is released alongside a new platform version, providing compatibility shims to newly added APIs as well as new features.

MihaMarkic commented 8 years ago

That makes sense. It seemed a bit odd behavior to me, since appcompat 23.x worked even with 5.1 (v22). Futhermore I installed only 7.1.x SDK which wasn't picked by VS/compile target and I had no option to set it. Anyway, installing 7.0 SDK and setting compilation to latest version (or 7.0) solves it. Thanks for the details.