locked
How to solve Android.Views.InflateExceptions that appear after upgrading Visual Studio for Mac? RRS feed

  • Question

  • User366382 posted

    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.

    Wednesday, August 22, 2018 9:02 PM

Answers

  • User366382 posted

    Alright. Well thanks for checking and being so responsive. At least installing the upgrade fixed the issue. I will mark this as the answer in case anyone else encounters this.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, September 12, 2018 2:40 AM

All replies

  • User327754 posted

    @rbrettj said: 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.

    Hi @rbrettj,

    Simply set the target version to v9(Pie) and also update all your nuget packages to latest version.

    Thursday, August 23, 2018 7:51 AM
  • User366382 posted

    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.

    Thursday, August 23, 2018 1:43 PM
  • User327754 posted

    @rbrettj said: 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.

    Thursday, August 23, 2018 3:08 PM
  • User366382 posted

    No, I cannot share anything but snippets, sorry.

    Thursday, August 23, 2018 3:12 PM
  • User327754 posted

    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.

    Friday, August 24, 2018 6:33 AM
  • User366382 posted

    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.

    Friday, August 24, 2018 8:37 PM
  • User21936 posted

    @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.

    Tuesday, August 28, 2018 1:55 AM
  • User366382 posted

    Yeah, that's one of the first things I tried, actually. It must be something else.

    Tuesday, August 28, 2018 1:57 PM
  • User21936 posted

    @rbrettj said: 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?

    Wednesday, September 12, 2018 1:42 AM
  • User366382 posted

    I downloaded and installed the latest update for Visual Studio for Mac which came out today (9/11/18) I believe, which solved the issue. Unfortunately, I'm not sure what exactly fixed it, so if there's a way to easily track that down, then it can be posted here and I'll accept as an answer. Thanks for checking in, @JGoldberger .

    Wednesday, September 12, 2018 2:03 AM
  • User21936 posted

    @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.

    Wednesday, September 12, 2018 2:17 AM
  • User366382 posted

    I guess I was more interested if you knew exactly what it was that fixed it, since there were several fixes in the update. I'm aware that with the general ambiguity of the post, along with the various items within the update, pinpointing the exact fix would be difficult to do. Thanks anyway. I'm also aware that dealing with the occasional annoyance with Xamarin/VS for Mac is much better than trying to learn two brand new IDEs and the intricacies of Obj-C/Swift and Java/Kotlin, so thanks for that too.

    Wednesday, September 12, 2018 2:24 AM
  • User21936 posted

    I looked over the release notes and did not see anything obvious.

    Wednesday, September 12, 2018 2:37 AM
  • User366382 posted

    Alright. Well thanks for checking and being so responsive. At least installing the upgrade fixed the issue. I will mark this as the answer in case anyone else encounters this.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, September 12, 2018 2:40 AM