我有一个情况,
我已经从分支中提取了最新更改,并尝试使用tns run android
命令运行该应用程序。
该应用已成功启动,但API调用受到限制,一旦应用启动,就会引发错误。
我也回答了this,但这似乎不是问题所在。因为对于其他团队成员来说,它工作正常。 :/
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...
答案 0 :(得分:3)
从Android 9.0(API级别28)开始,默认情况下禁用明文支持。
使用android:usesCleartextTraffic
标志更新清单文件。
<application ... android:usesCleartextTraffic="true" ...>
答案 1 :(得分:3)
转到: your-project\App_Resources\Android\src\main\AndroidManifest.xml
通过将android:usesCleartextTraffic="true"
添加到<application></application>
标记中的现有规则中来更新清单,如下所示
<application
...
...
android:usesCleartextTraffic="true"
...
...
</application>