简体   繁体   English

Visual Studio 2015 Xamarin冻结

[英]Visual Studio 2015 Xamarin freezing

I have an Android app on Visual Studio 2015 with Xamarin and it is freezing frequently. 我在带有Xamarin的Visual Studio 2015上有一个Android应用程序,它经常冻结。

The only scenario I can reproduce every time is right after deploy. 我每次都能重现的唯一场景是在部署之后。 VS freezes right after the app is deployed on emulator or device. 在将应用程序部署到模拟器或设备上后,VS会立即冻结。 The app works fine, but the VS stands frozen for several seconds. 该应用程序运行正常,但VS冻结了几秒钟。 It also freezes in other scenarios too. 它还会在其他情况下冻结。

VS doesn't show the "not responding" message no matter what I do. 无论我做什么,VS都不会显示“不响应”消息。 It seems like it's doing some background work and it's not really frozen, but I can't figure out what the problem is. 似乎它正在做一些后台工作,并且还没有真正冻结,但是我无法弄清楚问题出在哪里。

I recreated my project from scratch and the problem started to happen again when I added my resources and installed some NuGet packages (appcompat v7 and firebase cloud messaging). 我从头开始重新创建了项目,当我添加资源并安装了一些NuGet程序包(appcompat v7和firebase云消息传递)后,问题又再次发生。

I'm guessing it's somehow related to VS not recognizing some attributes in some layout files, like 我猜想这与VS无法识别某些布局文件中的某些属性有关,例如

如图所示 .

1 - Any help on the freezing problem? 1-关于冻结问题有帮助吗?

2 - What can I do to VS recognize those attributes? 2-我怎样做才能让VS识别这些属性?

3 - Can I configure the resources.cs to be regenerated only on build? 3-我可以将resources.cs配置为仅在构建时重新生成吗?

Update 更新

Found this , but didn't worked for me! 找到 ,但是对我没用!

Update 2 更新2

Ok, now I'm 100% sure the problem is with the generation of android resources. 好的,现在我100%确定问题出在android资源的生成上。 The aapt.exe is the villain of this history, but I still can't make it stop executing and freezing Visual Studio every time. aapt.exe是这个历史的反面,但是我仍然不能让它每次都停止执行并冻结Visual Studio。 Is there some setting to ignore xml errors on layout files or something like that? 是否有一些设置可以忽略布局文件上的xml错误或类似内容?

I am the guy who created the bugzilla post you are referencing. 我是创建您所引用的bugzilla帖子的人。

Are you sure you have the <AndroidResgenExtraArgs>--no-crunch </AndroidResgenExtraArgs> on the right place? 您确定在正确的位置安装了<AndroidResgenExtraArgs>--no-crunch </AndroidResgenExtraArgs>吗? It must be inside the configuration you are using, ie the .csproj must be like this if you are deploying in Debug | AnyCPU 它必须在您正在使用的配置中,即,如果要在Debug | AnyCPU Deploy中进行部署,则.csproj必须像这样Debug | AnyCPU Debug | AnyCPU configuration: Debug | AnyCPU配置:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AndroidResgenExtraArgs>--no-crunch </AndroidResgenExtraArgs>

(also notice the trailing space after --no-crunch ) (另请注意--no-crunch之后的尾随空格)

BTW I also have trouble with aapt.exe when installing Nugets and --no-crunch does not help with this. 顺便说一句,当我安装aapt.exe时,我对aapt.exe也有麻烦,而--no-crunch对此无济于事。 What helps is temporarily renaming aapt.exe to aapt2.exe - Visual Studio does not run the aapt process, because it can't find the exe file and Nuget installations are fast. 临时将aapt.exe重命名为aapt.exeaapt2.exe帮助-Visual Studio不会运行aapt进程,因为它找不到exe文件并且Nuget的安装速度很快。 But this would probably not work for build and deploy, I think it throws an error. 但这可能不适用于构建和部署,我认为这会引发错误。

Well, after trying a lot of stuff I made a lucky guess and it worked. 好吧,在尝试了很多东西之后,我做出了一个幸运的猜测,并且成功了。

I was looking to my csproj and noticed some weird things, like: 我一直在寻找我的csproj,发现一些奇怪的东西,例如:

<ItemGroup>
    <AndroidResource Include="Resources\layout\onefile.axml" />
</ItemGroup>
<ItemGroup>
    <AndroidResource Include="Resources\layout\anotherfile.axml" />
</ItemGroup>
<ItemGroup>
    <AndroidResource Include="Resources\layout\onemorefile.axml">
        <SomeOtherAttributes />
    </AndroidResource>
</ItemGroup>

So I imagined that organizing the ItemGroups would worth a try and put all ItemGroups (class, layout, image, string, etc) together like: 因此,我认为组织ItemGroups值得一试,将所有ItemGroups(类,布局,图像,字符串等)放在一起,例如:

<ItemGroup>
    <AndroidResource Include="Resources\layout\onefile.axml" />
    <AndroidResource Include="Resources\layout\anotherfile.axml" />
    <AndroidResource Include="Resources\layout\onemorefile.axml" />
</ItemGroup>

And it worked beyond what I expected. 它的工作超出了我的预期。 Not only fixed my freezing problems... it made VS faster than before of my freezing problems... REALLY faster! 不仅解决了我的冻结问题……它使VS比以前的冻结问题更快……真正快了!

I don't know if reorganizing the csproj file can cause any kind of problems, but I'll do the same with other projects and see what happen. 我不知道重新组织csproj文件是否会导致任何类型的问题,但是我将对其他项目进行同样的操作,然后看看会发生什么。

I did a quick research about csproj and ItemGroup and found nothing relevant... I believe it's kind a bug! 我对csproj和ItemGroup进行了快速研究,但没有发现任何相关问题……我相信这是一个错误!

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

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