网络安全配置未指定,使用默认平台。 - Android Log

我正在尝试通过数据库 000webhost.com. 每当我启动应用程序时,我继续收到事件日志中显示的此消息 android studio. 有谁知道如何解决这个问题? 对此,我真的非常感激!
已邀请:

裸奔

赞同来自:

我也有同样的问题。 请将此行添加到清单中的应用程序标记。 我希望它还可以帮助你。


android:usesCleartextTraffic="true"

小明明

赞同来自:

你得到的消息不是错误; 它只是让您知道您不使用网络安全配置。 如果要添加其中一个,请查看开发人员网站上的此页面。 Android:
https://developer.android.com/ ... .html
.

奔跑吧少年

赞同来自:

我有同样的问题。 这不是网络分辨率,而是一个流量问题。 下面的代码帮助我解决了这个问题。 维持


super.onCreate/savedInstanceState/;
setContentView/R.layout.activity_main/;
if /android.os.Build.VERSION.SDK_INT > 9/
{
StrictMode.ThreadPolicy policy = new
StrictMode.ThreadPolicy.Builder//.permitAll//.build//;
StrictMode.setThreadPolicy/policy/;
}

三叔

赞同来自:

退房 url, 它必须使用

协议

https, 但不是

http

, 在我的情况下改变 http 在 https 在 url 解决了这个问题。

知食

赞同来自:

我有一个凌空的问题,但这是我的决定:

在宣言中 Android, 在申请中 tag 添加:


android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"


在文件夹中创建 xml 这个文件 network_security_config.xml 并写下以下内容:


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


在标签应用程序中,添加此标记:


<uses-library android:name="org.apache.http.legacy" android:required="false"></uses-library>

龙天

赞同来自:

有时候是这样的 api 28 更高,因为不再接受 http, 如果要接受请求,您需要更改 http 或者 localhost.

创建文件。 XML
https://i.stack.imgur.com/OByNq.png
XML

将以下代码添加到创建的新文件中。 XML
https://i.stack.imgur.com/DyrHF.png

添加它 AndroidManifest.xml
https://i.stack.imgur.com/JgILJ.png

要回复问题请先登录注册