angular - Nativescript:未知 URL 的 HTTP 失败响应
问题描述
我有一种情况,我已经从我的分支中提取了最新的更改并尝试使用tns run android
命令运行应用程序。该应用程序已成功启动,但 API 调用受到限制,一旦应用程序启动就会引发错误。
我也经历了这个答案,但这似乎不是问题。因为对于其他团队成员来说,它工作正常。:/
err {
JS: "headers": {
JS: "normalizedNames": {},
JS: "lazyUpdate": null,
JS: "headers": {}
JS: },
JS: "status": 0,
JS: "statusText": "Unknown Error",
JS: "url": null,
JS: "ok": false,
JS: "name": "HttpErrorResponse",
JS: "message": "Http failure response for (unknown url): 0 Unknown Error",
JS: "error": {
JS: "originalStack": "Error: java.io.IOException: Cleartext HTTP traffic to elk.chennai-volunteer-294695.staging.c66.me not permitted\n at new ZoneAwareError (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/
tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:1298:33)\n at onRequestComplete (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:
45:34)\n at Object.onComplete (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:37:13)",
JS: "zoneAwareStack": "Error: java.io.IOException: Cleartext HTTP traffic to elk.chennai-volunteer-294...
解决方案
从 Android 9.0(API 级别 28)开始,默认情况下禁用明文支持。
android:usesCleartextTraffic
使用标志更新清单文件。
<application ... android:usesCleartextTraffic="true" ...>
推荐阅读
- java - 在java中解析一个SQL语句拆分条件
- symfony - 外键(不想编辑)错误
- android - 我如何解决在android的片段中集成谷歌地图
- java - 无法在 jxbrowser-java 中设置地理定位权限
- vuejs2 - 如何在 Vuetify 中为图像制作材质框
- sql - 谁能帮助我如何创建任何人都可以通过互联网访问的 SQL 数据库?
- jenkins - Jenkins:它如何查找 Jenkinsfile 位置
- java - 在 tomcat spring 项目上运行 HotswapAgent 的异常
- core-data - 线程1:断点1.1
- python - 根据数据框块将不同的值分配到新列中