Android模拟器显示”…应用程序未响应”

huangapple go评论72阅读模式
英文:

Android Emulator says "...App isn't responding"

问题

在显示新对话框(实际上是一个ContentView)后,我的Android模拟器显示“...应用未响应”,并带有“关闭应用”和“等待”按钮。

这可能是我弄错的问题吗,还是模拟器相关的问题?有没有什么方法可以预防或修复这个问题?

我有点担心是我的错,可能是我没有正确处理某些事情,导致应用在真实设备上遇到问题,而不仅仅是在模拟器上。

我正在使用VS 2022和在VS的调试中启动的“Pixel 5 - API 33(Android 13.0 - API 33)”模拟器。

有什么建议吗?

英文:

After displaying a new Dialog (actually it is a ContentView) my Android Emulator says "...App isn't responding" with a "Close App"- and a "Wait"-Button.

Is this probably something I screwed up or is this an Emulator related issue? Is there anything I can do to prevent or fix this?

I am a bit affraid that is my fault with something I did not handle correctly so that the App runs into issues on the real device not just the emulator.

I am working with VS 2022 and the "Pixel 5 - API 33 (Android 13.0 - API 33)" Emulator started in Debug of VS.

Any hints?

答案1

得分: 3

以下是翻译好的部分:

"This can happen even if your code is good. Once it happens, its likely to keep happening."

"即使您的代码没问题,这种情况仍可能发生。一旦发生,很可能会持续发生。"

"After you click 'Wait', are you able to interact with the dialog? If so, then its likely just emulator has gotten messed up."

"在点击“等待”后,您能够与对话框互动吗?如果可以,那么很可能只是模拟器出现问题了。"

Fixes to try:
(1) Delete app from emulator, download it again. This helps ensure a clean start.
"尝试的解决方法:
(1) 从模拟器中删除应用,然后重新下载。这有助于确保干净的启动。"

(2) IF still happening, Use Tools / Android / Android Device Manager. Select emulator, Stop it if running, do "Reset to Defaults" (just clears some internal settings) or "Factory Reset" (completely resets device to original factory condition). Quit and Restart Visual Studio.
"(2) 如果问题仍然存在,请使用工具 / Android / Android 设备管理器。选择模拟器,如果正在运行,请停止它,然后执行“重置为默认值”(只清除一些内部设置)或“恢复出厂设置”(完全将设备恢复到原始出厂状态)。退出并重新启动Visual Studio。"

英文:

This can happen even if your code is good. Once it happens, its likely to keep happening.

  • After you click "Wait", are you able to interact with the dialog? If so, then its likely just emulator has gotten messed up.

Fixes to try:
(1) Delete app from emulator, download it again. This helps ensure a clean start.
(2) IF still happening, Use Tools / Android / Android Device Manager. Select emulator, Stop it if running, do "Reset to Defaults" (just clears some internal settings) or "Factory Reset" (completely resets device to original factory condition). Quit and Restart Visual Studio.

答案2

得分: 0

还有另一个可能导致这个问题的来源。这是一个非常严重的问题。
如果你开始收到这个错误信息 - 你需要检查:

  • 所有与UI交互的代码是否在UI线程上执行。
  • 所有传递给你调用的UI元素方法的对象是否也是在UI线程上创建的。

否则,你的UI在某个时刻会变得不响应,然后会出现问题。MainThread.BeginInvokeOnMainThread在这里是你的朋友。

另一个重要的事情是尽量避免手动设置控件属性,而是在可能的情况下使用数据绑定。

英文:

There is also another possible source of this issue. A very serious one.
If you start receiving this - you need to check that

  • all the code that interacts with UI is doing it on the UI thread.
  • all objects that are passed to methods of the UI elements you are
    calling are created on the UI thread as well.

Otherwise your UI will become unresponsive at some point and there'll be trouble. MainThread.BeginInvokeOnMainThread is your frined here

Also another important thing is avoiding setting control properties manually and instead using bindings wherever possible.

答案3

得分: 0

我的应用程序非常简单,在物理设备上运行没有任何问题。但在模拟器上,我每隔几秒钟就会收到这个消息("应用未响应")。

我的模拟器设置了只有1GB的RAM。我将RAM的数量增加到2GB,问题就消失了。我在模拟Pixel 5,并使用API 33。

英文:

My app was very simple and it worked on physical devices without any problems. But on an emulator, I was receiving this message every couple of seconds ("App isn't responding").

My emulator was set to have only 1 GB of RAM. I increased the amount to 2GB and the problem disappeared. I was emulating Pixel 5 with API 33.

huangapple
  • 本文由 发表于 2023年3月9日 16:57:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75682336.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定