简体   繁体   中英

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

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: 错误图像

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM