将设备更新为Android Pie 9.0后无法加载视图 [英] Views not loading after updating device to Android Pie 9.0

查看:159
本文介绍了将设备更新为Android Pie 9.0后无法加载视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将手机更新为Android 9.0。我正在开发的应用在早期的Android版本中运行良好。但是,更新后,某些需要互联网连接的视图无法加载。在其位置显示空白。

I recently updated my phone to Android 9.0. The app which I was developing was working fine in earlier Android version. But after the update some views which require internet are not loading. Blank spaces are being displayed in their places.

它有一个 ViewPager 作为横幅,在类别和交易下分别具有2个 RecyclerView 。他们都需要互联网来加载数据。

It has a ViewPager as banner and 2 RecyclerView below categories and deals respectively. They all require internet to load data.

我不知道Android Pie是否需要任何额外的权限或依赖项。

I don't know know if any extra permissions or dependencies are required in Android Pie.

日志显示

NetworkDispatcher.run:未处理的异常java.lang.NullPointerException :尝试在空对象引用
上调用虚拟方法'int java.lang.String.length()'java.lang.NullPointerException:尝试调用虚拟方法'int java.lang.String.length()'对空对象的引用

推荐答案

尝试这些解决方案


解决方案1)

Solution 1)

清单文件

android:usesCleartextTraffic="true"

如下所示

<application
            android:name=".ApplicationClass"
            android:usesCleartextTraffic="true"
            android:networkSecurityConfig="@xml/network_security_config"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">

清单的应用程序标签中添加此标签文件

Add this tag in application tag in manifest file


解决方案2)

Solution 2)

添加 android:networkSecurityConfig = @ xml / network_security_config 在应用程序标记中

<application
        android:name=".ApplicationClass"
        android:networkSecurityConfig="@xml/network_security_config"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

其中 network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

在res目录下创建xml,然后n etwork_security_config.xml xml 文件夹中的$ c>

Create xml under res directory and then network_security_config.xml in xml folder

有关更多信息

https://developer.android.com/about/版本/pie/android-9.0-changes-28

下载无法在Android Pie 9.0(Xiaomi mi A2)中运行的Manger

这篇关于将设备更新为Android Pie 9.0后无法加载视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆