ERR_CLEARTEXT_NOT_PERMITTED in debug app on Android

I’m still working on getting my movie database application working and I found out how to remotely view the error messages on the app in Chrome, so now I see as I type and the server is called, I get the following error message:

GET http://www.omdbapi.com/?s=Bat&type=&apikey=999999 net::ERR_CLEARTEXT_NOT_PERMITTED

It appears that this should be able to be solved by putting a line in the Android Manifest file, which I should be able to do by adding the following line to the config.xml

android:usesCleartextTraffic="true"

Which I did (see below)

        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
            <application android:usesCleartextTraffic="true" />
        </edit-config>

I’m still getting the error message however, even after re-deploying and reconnecting the debugging.

Anyone have any experience on how to solve this issue on Android?

9 Likes

[SOLUTION] On top of your config.xml file add this code:

    <access origin="*" />
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:usesCleartextTraffic="true" />
    </edit-config>
    <allow-navigation href="*" />

It works for me.

8 Likes

It gives me this error: :app:mergeDebugResources. Anyone got the same problem?

Hi @pabloo87 !

In that case, I suggest you to do as follows:
ionic cordova platform remove cordova

After this do that:
ionic cordova platform add cordova@7

And try again:
ionic cordova run android --livereload

Please, let me know if it helps you!

That seems to totally screw things up.

Unable to load PlatfromApi from platform. Error [Err_UNHANDLED_ERROR]" Unhandled error. (Does not appear to implement platform Api.)
Unhandled error. (The platform “cordova” does not appear to be a valid cordova platform. It is missing API.js. cordova not supported.)

And now I can re-install it.

Oh joy.

Thanks for the suggestion but i solved the problem in a different way.

1 Like

Can you tell me how you solved the problem?

Yes, i modified network_security_config.xml file changing <domain>localhost</domain> to <domain>served_ip</domain>, after the last ionic update the served ip it’s “localhost” so there is no need to change the file anymore. I recommend you to update the app

The purpose is just to let you to reinstall the Cordova version 7.

Doesn’t work for me, any idea?

Use the below command to livereload
ionic cordova run android --device -l --ssl --debug

2 Likes

I had updated IONIC CLI (v5) and Android platforms-tools to v28.

ionic cordova run android -l

After, you need update your config.xml

 <access origin="*" />
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
        <application android:usesCleartextTraffic="true" />
    </edit-config>
3 Likes

yh, i got the same issue after adding it

Adding <allow-navigation href="*" /> in my config.xml solves the issue

8 Likes

I had the same error “Err-cleartext-not-permitted-in” coming in debug console.
I resolved it by adding IP address of the API url in
network_security_config.xml file changing <domain>localhost</domain>

2 Likes

goto project/resources/android/xml/network_security_config.xml

<domain-config cleartextTrafficPermitted="true">

        <domain includeSubdomains="true">localhost</domain>
        <domain includeSubdomains="true">http://www.omdbapi.com</domain>
 <domain includeSubdomains="true">http://www.yourdomain.in</domain>
    <domain includeSubdomains="true">http://serveripaddress</domain>
    </domain-config>
6 Likes

For me this worked! Apparently this issue comes on the latest phones.

this answer solve my problem, many thanks!

i have this enviroment btw

Ionic CLI : 5.2.3
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.2

Cordova:
Cordova CLI : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4

that’s how I solved the problem.

I add this line
android:usesCleartextTraffic="true"
to
platforms/android/app/src/main/AndroidManifest.xml

<application android:hardwareAccelerated="true" 
android:icon="@mipmap/icon" 
android:label="@string/app_name" 
android:supportsRtl="true" 
`android:usesCleartextTraffic="true"`>

It looks that way.

20 Likes

this worked for me
thanks