I have a longstanding Android project that was working just fine up until the day Visual Studio for Mac was updated to include support for Android v9 (Pie). I am using several support Nuget files, such as Xamarin.Android.Support.v7.RecyclerView and have had no issues in the past. Although I am not targeting v9 at all, and have explicitly targeted 8.1 in the project settings as well as the manifest, something must have broken with the update. The exception thrown is an Android.Views.InflateException about being unable to inflate an android.support.v7.widget.RecyclerView, but if I drill down from there, the cause appears to be a Java.Lang.ClassNotFoundException because it couldn't find android.support.v7.recyclerview.R$styleable. I checked the bin folders, and there does exist a Xamarin.Android.Support.v7.RecyclerView.dll file, so I don't know what the problem is. My application throws this exception on both the Emulator and an actual device. Any help would be appreciated.
Answers
Hi @rbrettj,
Simply set the target version to v9(Pie) and also update all your nuget packages to latest version.
But @Ahsan_Siddique, I don't want to target v9 (Pie), I want to target 8.1 (Oreo). Also, when last I checked, there are no updates to the Nuget packages I am using, probably because Xamarin has yet to create v9 bindings for them.
Can you share your github repo. Maybe i could do something for you.
No, I cannot share anything but snippets, sorry.
By the way, why are you secring to target v9(Pie)?? If you will target v9 then you can also use on 8.1 supported devices.
Because Pie just came out, and I have no device to ensure the application doesn't crash immediately on it, and have no interest in taking advantage of the new features of Pie, and have no time to dedicate to developing more features to the application. As it stands, what I am asking for should be completely reasonable. I shouldn't need to target Pie or anything like that just to have my application not crash upon foolishly installing updates to Visual Studio for Mac. I appreciate your attempts at helping, but the "solution" of targeting Pie is not a solution I'm currently interested in. Thanks.
@rbrettj
Did you try to fully clean and rebuild your project after the update (always a good idea to do this)?
By "fully" clean and rebuild, I mean using Finder to delete all of the bin and obj folders for every project in your solution. This will make sure to clean any old build artifacts that may be left over from the old version of Xamarin.
Yeah, that's one of the first things I tried, actually. It must be something else.
Have you resolved this yet? If not, can you post the contents of your .csproj file for the Android project?
@rbrettj
Excellent, thanks for letting me know.
I did run into an issue once recently where Android 9.0 was being targeted even though it was not installed and I had "Use Latest Installed Version" for the "Compile with" project property. It shows (9.0) as the Android version in use even though it was not installed. Selected Android 8.1 explicitly resolved that on my end. So it may have been that issue, but you said you were selecting 8.1 explicitly, so I do not know if that is what you were hitting. Anyway, if updating resolved it, then great... another bug fixed. Since it is unlikely that the engineering team would backport such a fix to earlier versions of VS for Mac, there is not much use in figuring out exactly what happened on your end.
I looked over the release notes and did not see anything obvious.