I developed alot in angular and decided that I would like to try develop a application using NativeScript.
Im using tns preview
to scan QR code of application with the playground application on my OnePlus 6t using OxygenOS 10.3.1. The phone is connected to the same wifi. I Also have a nodejs server where i would like to get some data from running on localhost:3000.
However when i try to make the request within the application on my phone get this error:
Error: java.io.IOException: Cleartext HTTP traffic to 192.168.1.4 not permitted\n at onRequestCom...
So after a bunch of reading a understood that i was supposed to add to my App_Resources/Android/src/main/AndroidManifest xml file this:
`
<application
.
.
android:usesCleartextTraffic="true"
.
.
>
`
After this i restarded the application since it didnt direcly push the updates to the application on the phone (PlayGround). But nothing changed, same error occured.
So i tried to add a network_security_config.xml and wrote this: `
<?xml version="1.0" encoding="utf-8" ?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">10.0.2.2</domain> <!-- Debug port -->
<domain includeSubdomains="true">xamarin.com</domain>
<domain includeSubdomains="true">192.162.1.4:3000</domain> <!--My localhost domain on pc-->
</domain-config>
</network-security-config>
`
and then in my Manifest: `
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="10000" android:versionName="1.0">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:networkSecurityConfig="@xml/network_security_config" android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/AppTheme" >
<activity android:name="com.tns.NativeScriptActivity" android:label="@string/title_activity_kimera" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode" android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity" />
</application>
</manifest>
`
Same error occures. Its like the changes doesnt get pushed to the application tns platform remove android
and then tns platform add android
, stil didnt work, the same error again.
It feels like its not updating, but im not sure. Help me out :D
I've tried Android 8: Cleartext HTTP traffic not permitted
My package.json: `
{
"nativescript": {
"id": "org.nativescript.frontendapp",
"tns-ios": {
"version": "6.4.0"
},
"tns-android": {
"version": "6.4.1"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"@angular/animations": "~8.2.0",
"@angular/common": "~8.2.0",
"@angular/compiler": "~8.2.0",
"@angular/core": "~8.2.0",
"@angular/forms": "~8.2.0",
"@angular/platform-browser": "~8.2.0",
"@angular/platform-browser-dynamic": "~8.2.0",
"@angular/router": "~8.2.0",
"@nativescript/theme": "~2.3.0",
"nativescript-angular": "~8.21.0",
"nativescript-permissions": "^1.3.8",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.4.0",
"tns-core-modules": "~6.4.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular/compiler-cli": "~8.2.0",
"@ngtools/webpack": "~8.2.0",
"nativescript-dev-webpack": "~1.5.0",
"typescript": "~3.5.3"
},
"gitHead": "d8bdf0799a219051f28f8abd7c258d2bf2fce6e1",
"readme": "NativeScript Application"
}
`