Bug 58121 - RecyclerView support library can't be used pre-Nougat
Summary: RecyclerView support library can't be used pre-Nougat
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.3 (15.2)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-07-13 02:19 UTC by James Ko
Modified: 2017-07-15 05:12 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Warnings from trying to use support libs from app targeting API level < 7.0 (66.61 KB, image/png)
2017-07-13 02:19 UTC, James Ko
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description James Ko 2017-07-13 02:19:43 UTC
Created attachment 23510 [details]
Warnings from trying to use support libs from app targeting API level < 7.0

Hi, I'm looking to use the following libraries in my Android app:

- Xamarin.Android.Support.v7.RecyclerView
- Xamarin.Android.Support.v7.CardView

This StackOverflow question https://stackoverflow.com/q/35023149/4077294 says that, from Java, RecyclerView and CardView are available since at least Lollipop. The answerers also say that the support libraries allow these controls to be used pre-KitKat. I was surprised when I found that right-clicking my app project in VS, going to Properties, and targeting the app to anything less than 'Android 7.0 (Nougat)' caused warnings. (see image 1)

When I tried to run my app despite the warnings, I got a Mono runtime error about a missing virtual method. See here: https://github.com/jamesqo/Repository/issues/69

Would it be possible to make the above libraries (and their dependencies, namely Xamarin.Android.Support.Core.UI, Xamarin.Android.Support.Compat, and Xamarin.Android.Support.Annotations) available on pre-KitKat devices?

Thank you for your time.
Comment 1 Jon Douglas [MSFT] 2017-07-13 04:17:52 UTC
James,

I believe this is a misunderstanding of how support libraries work mixed with a combination of the three SDK version values in Android.

These support libraries that are named "v7" means they support all the way back to API 7.

The problem you are running into is that the libraries you have installed REQUIRE a minimum of Android 7.0 (API 24). However your project has a compileSdkVersion of 6.0 which is not the minimum. Thus these methods that the support library depends on are not included when compiling your app and thus fail at runtime.

You can also see this noted as a dependency when you look at the nuget:

https://www.nuget.org/packages/Xamarin.Android.Support.v7.RecyclerView/

I would recommend reading up on these items here to understand fruther:

https://medium.com/google-developers/picking-your-compilesdkversion-minsdkversion-targetsdkversion-a098a0341ebd

Thus I am marking this bug as RESOLVED ANSWERED
Comment 2 James Ko 2017-07-13 16:20:28 UTC
Jon Douglas,

Thanks for your response. I now understand that by lowering the TargetFrameworkVersion in my app's .csproj to 6.0, I was lowering the compileSdkVersion instead of the minSdkVersion.

Just a question-- if TargetFrameworkVersion controls compileSdkVersion, how does one configure min/targetSdkVersion from a Xamarin.Android project?
Comment 3 Jon Douglas [MSFT] 2017-07-13 16:49:02 UTC
(In reply to James Ko from comment #2)
> Jon Douglas,
> 
> Thanks for your response. I now understand that by lowering the
> TargetFrameworkVersion in my app's .csproj to 6.0, I was lowering the
> compileSdkVersion instead of the minSdkVersion.
> 
> Just a question-- if TargetFrameworkVersion controls compileSdkVersion, how
> does one configure min/targetSdkVersion from a Xamarin.Android project?

You can look through our documentation on this subject found here:

https://developer.xamarin.com/guides/android/application_fundamentals/understanding_android_api_levels/#Project_API_Level_Settings

Note: Use the top right switcher to switch between VS and VS4Mac.
Comment 4 James Ko 2017-07-15 02:39:23 UTC
I looked through the instructions you linked to. I'm very confused because the docs show this image:

https://developer.xamarin.com/guides/android/application_fundamentals/understanding_android_api_levels/Images/vs-defaults-sml.png

But I see this in VS2017 (the min/targetSdkVersion selections are missing):

http://i.imgur.com/2tFgMD3.png

Should I file a new bug with the people who work on the Xamarin extension for VS?
Comment 5 Jon Douglas [MSFT] 2017-07-15 03:37:48 UTC
No bug is needed for this. In VS 2017 they were recently moved.

https://developer.xamarin.com/releases/vs/xamarin.vs_4/xamarin.vs_4.5/#androidprops

The other two items are under "Android Manifest".
Comment 6 James Ko 2017-07-15 05:12:17 UTC
OK, I see them now. Thanks for your patience :)