ERR_CLEARTEXT_NOT_PERMITTED error

An issue has emerged:
After communicating with the local server (192.168.1.9) with my mob. phone (from inside the network) and while trying to send data to a .php file via an Ajax call, I get

ERR_CLEARTEXT_NOT_PERMITTED.

I think I know that I have to insert :
android:usesCleartextTraffic="true"
at the application Tag, but I do not know where this is in AppStudio…

Any directions would be most appreciated…

Are you running as a web app or as a PhoneGap app?

Share your story with the AppStudio Community! Quarantine Stories

It will be used as a PhoneGap app.

When you got the error, were you running as a PhoneGap app or a web app?

Share your story with the AppStudio Community! Quarantine Stories

The app was compiled using phonegap when I got the error. I was using it as an app on my mob phone.

Dear, please add the below to config.xml

<widget
xmlns = "[https://www.w3.org/ns/widgets](https://www.w3.org/ns/widgets)"
xmlns:android="[http://schemas.android.com/apk/res/android](http://schemas.android.com/apk/res/android)"
xmlns:gap = "[http://phonegap.com/ns/1.0](http://phonegap.com/ns/1.0)"


<!-- Platforms: Customize as needed. -->
<platform name="android">
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
      <application android:usesCleartextTraffic="true" />
  </edit-config>
</platform>

BR.

Sorry for the very late reply, but your propose didn’t work.

I am listing my phonegap config file. When trying to compile using phonegap, I get :
java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed

config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<widget 
xmlns = "https://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.nsbasic.{id}"
versionCode = "{phoneGapBuildCounter}"
version = "{version}">
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:cdv="http://cordova.apache.org/ns/1.0">



<name>{title}</name>
<description>{description}</description>
<preference name="phonegap-version" value="{phoneGapVersion}" />

<icon src='{icon}' />
<preference name='SplashScreenDelay' value='2000' />
<preference name='AutoHideSplashScreen' value='true' />
<plugin name='cordova-plugin-splashscreen' source='npm' />

<preference name="permissions" value="none"/>
<!-- sample preference specifications -->
<!-- <preference name="autorotate" value="false" readonly="true"/> -->
<!-- <preference name="orientation" value="default" /> -->
<!-- <preference name="fullscreen" value="true" /> -->

<!-- Platforms: Customize as needed. -->
<gap:platforms>
   <gap:platform name="android" />
   <gap:platform name="ios" />
</gap:platforms>

<platform name="android">
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
      <application android:usesCleartextTraffic="true" />
  </edit-config>
</platform>



<plugin name="cordova-plugin-statusbar" source="npm" />
  <preference name="StatusBarOverlaysWebView" value="{phoneGapStatusBarOverlay}" />
  <preference name="StatusBarBackgroundColor" value="{phoneGapStatusBarColor}" />
  <preference name="StatusBarStyle" value="{phoneGapStatusBarStyle}" />

<plugin name="cordova-plugin-whitelist" source="npm" />
  <allow-navigation href="*" />
  <access origin="*" />
  <allow-intent href="*" />
</widget>

Any suggestions?

Does the Android resource compilation failed message go away if you delete the new code?

If it does, there may be a problem in that code. If not, there;s a problem elsewhere in your config.xml.

Yes the message goes away if I remove the following portion:

<platform name="android">
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
      <application android:usesCleartextTraffic="true" />
  </edit-config>
</platform>

Code compiles to PhoneGap but as expected the issue persists.

This discussion may help:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.