关于angular:Nativescript:未知URL的HTTP故障响应

Nativescript: HTTP failure response for unknown URL

我有一个情况,
我已经从分支中提取了最新的更改,并尝试使用tns run android命令运行该应用程序。
该应用程序已成功启动,但API调用受到限制,一旦应用程序启动,就会引发错误。

我也回答了这个问题,但这似乎不是问题所在。因为对于其他团队成员来说,它工作正常。 :/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    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\
    at new ZoneAwareError (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/
tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:1298:33)\
    at onRequestComplete (file:///data/data/org.nativescript.chennaivolunteersapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:
45:34)\
    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标志更新清单文件。

1
 


转到:your-project\\App_Resources\\Android\\src\\main\\AndroidManifest.xml

通过将android:usesCleartextTraffic="true"添加到</application>标记中的现有规则来更新清单,如下面的

所示

1
2
3
4
5
6
7
<application
    ...
    ...
    android:usesCleartextTraffic="true"
    ...
    ...
</application>