应用程序无法在 android 9 Pie 中运行,仅显示黑屏

Application not working in android 9 Pie only showing black screen

我的应用程序在 android 9 Pie 中除外。我在我的应用程序上没有看到任何错误,并且一切正常。我还没有找到关于这个错误的任何解释。

我的应用程序在我登录应用程序后出现错误,然后它只显示一个空白的黑色布局。有没有人遇到过这种错误?请帮我。谢谢。

2019 年 8 月 3 日更新

我找到了答案,这是由 android pie 的最新要求引起的,如果不将 apache.http.legacy 设置为 andorid:required,设备无法将数据发送到服务器 HTTP ="假.

我最近遇到了 Android 9 的相同问题,但我不得不为不同的屏幕使用一些 URL。所以我将 android:usesCleartextTraffic="true" 添加到 Manifest 并且它起作用了,但我们不想为此损害整个应用程序的安全性。因此,解决方法是将链接从 HTTP 更改为 https.But,如果您必须仅使用 http 与您的应用程序通信,那么这就是您的解决方案。

Add this in the Manifest file

android:networkSecurityConfig="@xml/security_config"

Add this in the Xml
<network-security-config>
<base-config cleartextTrafficPermitted="true"/>
<debug-overrides>
 <trust-anchors>
    <certificates src="system" />
    <certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>