Skip to content

[Bug]: Android Live Reload broken in Capacitor 5.7.2 #7323

@alextreppass

Description

@alextreppass

Capacitor Version

[warn] The bundledWebRuntime configuration option has been deprecated. Please,
use a bundler to bundle Capacitor and its plugins.
💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.7.2
@capacitor/core: 5.7.2
@capacitor/android: 5.7.2
@capacitor/ios: 5.7.2

Installed Dependencies:

@capacitor/cli: 5.7.2
@capacitor/core: 5.7.2
@capacitor/android: 5.7.2
@capacitor/ios: 5.7.2

Other API Details

yarn --version
3.2.1

OSX Sonoma 14.4.1

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Our capacitor.config.ts when running in live reload mode (-l external), has the following config:

server: {
  url: process.env.LIVE_RELOAD_SERVER_URL,
  cleartext: true,
},

LIVE_RELOAD_SERVER_URL is set as http://10.0.2.2:3000 for Android (as Android Studio treats the host machine's ip as 10.0.2.2), and http://0.0.0.0:3000 for iOS.

We are using this setup to proxy a local dev server running on port 3000 for fast iteration without having to run npx cap run + rebuild each time.

Issues

In 5.7.2 with Android, when going to the url capacitor's live-reload.ts generates (e.g. http://192.168.1.241:3000) the webpage does not load. There is an ERR_CLEARTEXT_NOT_PERMITTED error:
Screenshot 2024-03-08 at 9 53 39 am

It doesn't look like there have been updates to https://github.com/ionic-team/capacitor/blob/main/cli/src/util/livereload.ts since @IT-MikeS introduced it, so something else must be going on here.

Expected Behaviour

This worked great on 5.4.2:

  @capacitor/cli: 5.4.2
  @capacitor/core: 5.4.2
  @capacitor/android: 5.4.2
  @capacitor/ios: 5.4.2

The webview would load correctly.

Project Reproduction

https://github.com/alextreppass/capacitor-live-reload-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions