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

rbrettjrbrettj Member ✭✭

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.

Best Answer

  • rbrettjrbrettj ✭✭
    Accepted Answer
    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.

Answers

  • Ahsan_SiddiqueAhsan_Siddique PKMember ✭✭✭

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

  • rbrettjrbrettj Member ✭✭

    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.

  • Ahsan_SiddiqueAhsan_Siddique PKMember ✭✭✭

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

  • rbrettjrbrettj Member ✭✭

    No, I cannot share anything but snippets, sorry.

  • Ahsan_SiddiqueAhsan_Siddique PKMember ✭✭✭

    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.

  • rbrettjrbrettj Member ✭✭

    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.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

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

  • rbrettjrbrettj Member ✭✭

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

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

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

  • rbrettjrbrettj Member ✭✭
    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 .
  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

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

  • rbrettjrbrettj Member ✭✭
    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.
  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

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

  • rbrettjrbrettj Member ✭✭
    Accepted Answer
    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.
Sign In or Register to comment.