0

Newbie to NativeScript. I'm working on my first http request, and the request gets "stalled". That's the message in the network tab of the Chrome console when I launch "tns debug android".

The request works in the emulator's browser. The request works in my Angular Web project. The request works when I double-click on the request line in the network tabs.

Could it be some kind of permissions error. In the AndroidManifest I have both:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Any help would be greatly appreciated.

2
  • I don't think it's specific to any network permissions. Does this happen only with the calls you make to your server or it even happens with any endpoint, may be http://google.com for instance? Commented Nov 9, 2018 at 21:47
  • Good idea. I found a public testing api at jsonplaceholder.typicode.com. I created a get request using that as the endpoint, and it succeeded. Seems like there is something wrong in the structure of my request. Commented Nov 9, 2018 at 22:28

2 Answers 2

2

I think I found the answer. Tweaked the code and found this error:

java.io.IOException: Cleartext HTTP traffic to ... not permitted. I haven't been using https in dev so either I need to use it, or set some flag to cleartextTrafficPermitted=true.

Sign up to request clarification or add additional context in comments.

Comments

2

I have the same issue when using HTTP not HTTPS in dev environment as well.

The above answer is right but just thinking of making it more clear:

Put android:usesCleartextTraffic="true" in the application tag.

Example:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.