我有一个应用程序,可以在低于Android9的设备上完美运行。我刚刚在我的Manifest上实现了android:usesCleartextTraffic="true",以支持Android9和更高版本。问题是,在我的三星note 8上,应用程序运行良好,但在朋友的三星note 8上;即使网络连接良好,一些api调用也总是失败。可能的问题是什么?
发布于 2020-05-14 04:38:46
谢谢你的所有建议。为了解决我的问题,我做了一个吐司来显示设备正在调用的端点,并注意到%20被添加到我的参数中。%20表示存在空格,这是在应用程序上的用户注册期间出现的,当时没有问题。因此,为了解决这个问题,我在从edittext视图中获取文本时添加了一个trim(),以获得没有空格的精确细节,并且它工作得很好。
发布于 2020-05-01 20:24:22
我已经通过在res -> xml文件夹中创建network_security_config.xml解决了我的问题
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true"> /* your base url Eg: http://mide.awsnode.com/ */</domain>
<domain includeSubdomains="true"> /*--- another url (if have) */ </domain>
</domain-config>
</network-security-config>在清单中
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:logo="@drawable/new_logo_ag"
android:networkSecurityConfig="@xml/network_security_config" // define the xml
android:roundIcon="@drawable/new_logo_ag"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
tools:targetApi="n">也许这对你有帮助
https://stackoverflow.com/questions/61542110
复制相似问题