Flutter应用在释放模式下显示灰屏,但在调试模式下可以正常工作'DiagnosticsProperty <void>'

时间:2020-05-05 14:45:54

标签: android flutter https release

我注意到该应用程序在调试模式下运行良好,但是当我在手机上尝试apk时,该应用程序在加载屏幕后显示灰色屏幕。 当我使用https并添加所有权限时。

Httpclient在发布模式下不起作用(I / flutter(22182):引发了另一个异常:“ fr”的实例)

但是在Flutter android中可以在调试模式下工作

4 个答案:

答案 0 :(得分:26)

在调试模式下运行应用程序时,如果出现问题,则会看到带有日志的可怕的红色错误屏幕。在释放模式下,您只会看到灰色屏幕。

现在,当您在调试模式下运行应用程序时,有时会抛出一些错误,但是由于我们看到该应用程序在屏幕上运行正常,因此我们错误地忽略了它们,但是如果您在调试模式下打开日志,您将看到一些错误消息。

对我来说是这样的:

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown while applying parent data.:
Incorrect use of ParentDataWidget.

The ParentDataWidget Expanded(flex: 1) wants to apply ParentData of type FlexParentData to a RenderObject, which has been set up to accept ParentData of incompatible type StackParentData.

Usually, this means that the Expanded widget has the wrong ancestor RenderObjectWidget. Typically, Expanded widgets are placed directly inside Flex widgets.
The offending Expanded is currently placed inside a Stack widget.

我的应用在调试模式下运行完美,而Flutter仍然在后台抛出此错误。

现在,当我在发布模式下运行该应用程序时,我会看到一个灰色屏幕,这与在调试模式下运行完美的应用程序不同。

当我检查日志时,看到错误消息:

Flutter app show grey screen in release mode but works fine in debug mode Instance of 'DiagnosticsProperty<void>'

那么解决方案?

以调试模式运行您的应用并检查日志,我确定您会在其中找到问题。只要代码中有错误,更改混乱的通道就无济于事。

答案 1 :(得分:1)

首先,您检查AndroidManifest.xml (用于调试模式的AndroidManifest.xml文件与用于发布模式的AndroidManifest.xml文件不同。 检查目录:

android\app\src\debug\AndroidManifest.xml

和目录:

android\app\src\main\AndroidManifest.xml

即使您可以创建发布版本:

android\app\src\release\AndroidManifest.xml

尝试添加

<uses-permission android:name="android.permission.INTERNET" />

到目标AndroidManifest.xml)。

调试模式下的红色屏幕,就像发行版中的灰色屏幕 这意味着您有一个错误代码,但对于调试模式,此错误可能类似于警告,并且可能运行,并且在调试模式下您的应用程序看不到任何问题! 但是对于发布模式,您应该修复它! 像我这样: 我正在尝试将Position Widget放在Container Widget中,但出现此错误:

Another exception was thrown: Instance of ‘DiagnosticsProperty’
Incorrect use of ParentDataWidget.

我通过将Container更改为Stack来解决它。

答案 2 :(得分:0)

此问题已经存在一段时间了,这里是related issue

我遇到过这个问题,但这取决于代码。对我来说,我使用CacheNetworkImage issue#404传递了错误的imageUrl或null,这导致了灰屏。即使没有升级到1.17.1(以前的版本为1.12.13 + hotfix.8),我也无法正确处理UI,但现在一切都需要更加小心。

答案 3 :(得分:0)

我有一个类似的问题。在flutter upgrade之后,它在发布模式下也可以正常工作。
这些是我当前的版本:

相关问题