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?

1 Like

[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.

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.

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

1 Like

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>

yh, i got the same issue after adding it

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

2 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>

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>