Why am I getting JINativeWrapper.g.cs file not found error when running my Xamarin app?

Viewed 1080

When I try to run my Xamarin app on my M1 MacBook, it builds and works fine. But when I run this function:

async void loginHandler()
    {
        var loginText = login.Text;
        var passwordText = password.Text;
        var client = new HttpClient();
        var json = new StringContent(
            JsonConvert.SerializeObject(new { username = loginText, password = passwordText })
        );
        var result = await client.PostAsync("https://localhost:443/api/account/login", json);
        if (result.IsSuccessStatusCode)
        {
            var TokenJson = await result.Content.ReadAsStringAsync();
            //await DisplayAlert("alert", "message", "cancel");
        }
    }

        

It crashes and shows this error:error image

How can I fix it? I'm using visual studio 2022.

2 Answers

Try using an iOS emulator. Seems like Visual Studio needs to fix this problem with android emulators.

For me, my VS2022 instance was pointing to version 8 of the JDK. My Android app is targeting Android 12 (SDK 31). Once I updated my JDK to 17 (or 11+) I was no longer getting the error. Not sure if that will help anyone or not, but that is what worked for me.

Related