我无法消除Nativescript应用程序中的明文HTTP流量错误。我看到了所有相关的线程,并在我的应用程序中添加了以下配置:
在AndroidManifest.xml中添加:
<application
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config">
还将以下文件添加到两个位置: App_Resources / Android / src / main / res / xml / network_security_config.xml App_Resources / Android / xml / network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com</domain>
</domain-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
错误:
{“ originalStack”:“错误:java.io.IOException:在新的ZoneAwareError上,不允许对ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com的明文HTTP流量\ n在onRequestComplete(file:///data/data/data/com.app.app/files/app)上的file:///data/data/com.app.app/files/app/vendor.js:92106:33)\ n /vendor.js:131598:34)\n在Object.onComplete(file:///data/data/com.app.app/files/app/vendor.js:131587:13)“,” zoneAwareStack“:”错误:java.io.IOException:不允许对ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com的明文HTTP通信\在onRequestComplete(file:/// data / data / com .app.app / files / app / vendor.js:131598:34)[] \ n在Object.onComplete文件:/// node_modules \ tns-core-modules \ http \ http-request \ http-request.js: 43:0
在Android Emulator-Pixel_2_API_28:5554上运行
更新: 它可以在真实设备上运行。