question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: ERR_CLEARTEXT_NOT_PERMITTED

See original GitHub issue

Bug Report

Android throws ERR_CLEARTEXT_NOT_PERMITTED.

Capacitor Version

npx cap doctor output: Latest Dependencies: @capacitor/cli: 1.3.0 @capacitor/core: 1.3.0 @capacitor/android: 1.3.0 @capacitor/ios: 1.3.0

Installed Dependencies: @capacitor/ios not installed @capacitor/core 1.3.0 @capacitor/cli 1.3.0 @capacitor/android 1.3.0

[success] Android looking great! 👌

Affected Platform(s)

  • Android
  • iOS
  • Electron
  • Web

Current Behavior

Android does not open webview and shows ERR_CLEARTEXT_NOT_PERMITTED.

Solution

To solve the issue I had to add android:usesCleartextTraffic="true" in AndroidManifest.xml as suggested in https://stackoverflow.com/questions/54752716/why-am-i-seeing-neterr-cleartext-not-permitted-errors-after-upgrading-to-cordo

This is also described in https://developer.android.com/training/articles/security-config#CleartextTrafficPermitted:

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/AppTheme">

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:17
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
miqmagocommented, Oct 31, 2019

@jcesarmobile thanks, as you said this is an Android 9+ feature to move to https. But imo, when an app is in development stage, normally one should not take care of https, otherwise would mean to open 443 port in development machine, certificate issues and much more headaches. So it makes sense to add android:usesCleartextTraffic="true" in AndroidManifest.xml.

On the other hand, when capacitor compiles the app for production (where https should be mandatory), server.url is autoremoved, so it makes sense to remove android:usesCleartextTraffic="true" in AndroidManifest.xml.

Then I see a risk for developers to leave this option in AndroidManifest.xml and push to stores with this flag. I understand that this is not a big issue, but anyway it is an issue, don’t know if in the future Android is planning to penalize in some way apps using http, right now in the web it affects to SEO.

Maybe the issue is not a bug but a feature request, and also don’t really know if capacitor is the responsible of changing/alerting developer of this potencial error. Maybe should be a gradle script or similar. What I think is clear is that this is a developer experience issue.

2reactions
jcesarmobilecommented, Oct 31, 2019

It has to be manual, unless using something that handles it for you such as Ionic CLI. Not sure if Ionic CLI works with stencil apps, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix ERR_CLEARTEXT_NOT_PERMITTED Error for Websites
There's an easy solution to fix err_cleartext_not_permitted error and i.e. don't use insecure URLs. It is recommended to force HTTPs on your ...
Read more >
How to fix the "net::err_cleartext_not_permitted" Android ...
Developers can solve the net::err_cleartext_not_permitted Android Webview error by allowing only HTTPS URLs in their application. Any website ...
Read more >
ERR_CLEARTEXT_NOT_PERMI...
After upgrading to Cordova Android 8.0, I am seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors when trying to connect to ...
Read more >
How to fix net::ERR_CLEARTEXT_NOT_PERMITTED error
The proper solution for this error is to simply use HTTPS URLs for all of your endpoints and remove all unsecured URLs from...
Read more >
How to solve Cordova In App Browser Plugin Error: net
Learn how to prevent the net::ERR_CLEARTEXT_NOT_PERMITTED error from appearing in your Cordova application. ... After 2 years of working with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found