Search code examples
androidangularandroid-emulatornativescriptjson-server

Why my Emulator doesn't work with NativeScript?


I have uploaded my project here https://github.com/rezaee/conFusion, but when I try to run it using tns run android --device Pixel_2_API_29 it opens my emulator but show this error message on it's screen:

Error:0-Unknown Error Http failure response for https://10.0.2.2

I also tried the following lines as well but all gives the same error:

export const baseURL = "http://10.0.2.2:3000/";
export const baseURL = "http://192.168.1.5:3000/";
export const baseURL = "http://localhost:3000/";

Why this happens and how can I fix it?


Solution

  • After one month of trying, I found the following answer on the NativeScript's github:

    Test on API29 and the issue is that you are probably missing the cleartext permission in AndroidManifest.xml file.

    Set it here: your-application/app/App_Resources/Android/src/main/AndroidManifest.xml

    Setting android:usesCleartextTraffic in AndroidManifest.xml

    <application android:name="com.tns.NativeScriptApplication"
              android:allowBackup="true"
              android:icon="@drawable/opportuity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme"
              android:usesCleartextTraffic="true">