Nativescript: HTTP failure response for unknown URL

会有一股神秘感。 提交于 2019-11-27 06:35:12

问题


I have a situation, I have pulled the latest changes from my branch and trying to run the application using tns run android command. The app is launched successfully but the API call is restricted throwing an error as soon as the app starts.

I have also gone through this answer but that's not the problem it seems. Because for other team members it is working fine. :/

    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...

回答1:


Starting with Android 9.0 (API level 28), cleartext support is disabled by default.

Update your manifest file with the android:usesCleartextTraffic flag.

<application ... android:usesCleartextTraffic="true" ...>



回答2:


Go to: your-project\App_Resources\Android\src\main\AndroidManifest.xml

Update your manifest by adding android:usesCleartextTraffic="true" to existing rules in <application></application> tag, like as seen bellow

<application
    ...
    ...
    android:usesCleartextTraffic="true">
    ...
    ...
</application>


来源:https://stackoverflow.com/questions/54018049/nativescript-http-failure-response-for-unknown-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!