Skip to content

fix(cli): enable cleartext for live reload #7563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2024
Merged

fix(cli): enable cleartext for live reload #7563

merged 5 commits into from
Jul 17, 2024

Conversation

jcesarmobile
Copy link
Member

This PR enables cleartext when using live reload by directly writing into the capacitor-cordova-android-plugins's AndroidManifest.xml, and removes it once the command is stopped.

It no longer overrides the original extConfig object but instead modifies the platform's capacitor.config.json after sync.

Added a TODO to remove editExtConfigForLiveReload since it's no longer being used.
Added a TODO to remove the last param of editCapConfigForLiveReload as it's not being used.
Didn't remove any of them at the moment as people could be using the CapLiveReloadHelper directly, so removing them is breaking.

I've put the process.on('SIGINT' inside a promise to prevent multiple calls, it was being called three times.

There is an alternate PR, but it requires users to declare the cleartext themselves and doesn't work if using the --no-sync option.

closes #7323
closes #7528

@markemer markemer merged commit e06648f into main Jul 17, 2024
6 checks passed
@markemer markemer deleted the RDMR-186 branch July 17, 2024 16:47
@xEverth
Copy link

xEverth commented Jun 6, 2025

Hello,

Sorry for commenting on a long-merged PR, but since this change is still in the main branch I would like to ask the following to the PR author:

Would it be preferrable to use a match pattern for the clearTextString?
What happens if one uses string substitution in their AndroidManifest, e.g. android:usesCleartextTraffic="${usesCleartextTraffic}"?

Thank you

(I am not able to use the livereload option on an Android 10 device without using --ssl, I always get ERR_CLEARTEXT_NOT_PERMITTED even after configuring both the server in capacitor config and the networkSecurityConfig in the AndroidManifest to specifically allow for cleartext traffic.)

@jcesarmobile
Copy link
Member Author

This doesn't write on the user's AndroidManifest.xml but in a module which we generate for Cordova plugins and the whole AndroidManifest.xml is generated by the CLI.

If you have more questions you can ask on the Ionic Forums, on Ionic discord or on the discussions section of capacitor repository

@ionic-team ionic-team locked as resolved and limited conversation to collaborators Jun 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Android Live Reload broken in Capacitor 5.7.2
4 participants