简体   繁体   English

为什么我在运行 Xamarin 应用程序时收到 JINativeWrapper.g.cs 文件未找到错误?

[英]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.当我尝试在我的 M1 MacBook 上运行我的 Xamarin 应用程序时,它构建并运行良好。 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.我正在使用视觉工作室 2022。

Try using an iOS emulator.尝试使用 iOS 模拟器。 Seems like Visual Studio needs to fix this problem with android emulators.似乎 Visual Studio 需要用 android 模拟器解决这个问题。

For me, my VS2022 instance was pointing to version 8 of the JDK.对我来说,我的 VS2022 实例指向 JDK 的 8 版。 My Android app is targeting Android 12 (SDK 31).我的 Android 应用程序面向 Android 12 (SDK 31)。 Once I updated my JDK to 17 (or 11+) I was no longer getting the error.将 JDK 更新到 17(或 11+)后,我不再收到错误消息。 Not sure if that will help anyone or not, but that is what worked for me.不确定这是否会帮助任何人,但这对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的代码中出现 CS1001 错误? - Why am I getting a CS1001 error in my code? 我正在将控件从aspx.cs文件写入我的aspx文件。 为什么在尝试使用控件时出现此错误? - I'm writing a control to my aspx file from the aspx.cs file. Why am I getting this error when attempting to use the control? 使用.rsp文件进行构建时,为什么会出现错误CS0116? - Why am I getting error CS0116 when building using a .rsp file? 为什么我收到错误 CS0246:尝试使用 OpenHtmlToPdf 时找不到类型或命名空间名称? - Why am I getting error CS0246: The type or namespace name could not be found when trying to use OpenHtmlToPdf? 为什么我收到错误 CS0246:找不到类型或命名空间名称? - Why am I getting error CS0246: The type or namespace name could not be found? 如果我的代码中没有“静态”,为什么会出现 CS0120 错误? - Why am I getting error CS0120 if I have no “static” in my code? 为什么当我尝试使用 octokitnet 创建新文件时出现未找到错误? - Why i am getting a not found error when i try to create a new file with octokitnet? 为什么会出现此错误? (未找到文件异常) - Why am I getting this error? (File Not Found Exception) 为什么我会收到“错误 CS1056:意外字符 '$'”并在此处放置 $ 标记? 我的编译器有问题吗? - Why am I getting "error CS1056: Unexpected character '$'" putting a $ mark here? A problem with my compiler? 使用Xamarin IDE构建项目时出现资源未找到错误 - I am getting a resource not found error when building a project using the xamarin IDE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM