Skip to content
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

feat: add productFlavor support to --livereload --external #5252

Closed
sandor-biro opened this issue Nov 18, 2021 · 11 comments
Closed

feat: add productFlavor support to --livereload --external #5252

sandor-biro opened this issue Nov 18, 2021 · 11 comments

Comments

@sandor-biro
Copy link
Contributor

Feature Request

Description

Currently assembleDebug is hardcoded so there's no possibility to --livereload --external a given productFlavor.

productFlavors {
        versionA {
            applicationId "com.company.versionA"
        }

        versionB {
            applicationId "com.company.versionB"
        }

        versionC {
            applicationId "com.company.versionC"
        }
    }

Platform(s)

Android

Preferred Solution

Change the hardcoded const gradleArgs = ['assembleDebug']; (https://github.com/ionic-team/capacitor/blob/main/cli/src/android/run.ts#L22)

to a dynamic one, so various productFlavors can be generated correctly when using --livereload --external build args.

App should generate gradleArgs based on the given productFlavor i.e. assembleVersionADebug etc.

const arg = `assemble${flavour}Debug`;
const gradleArgs=[arg];

Alternatives

... remove extra product flavours from build.gradle while working, then remember copy them back.

Additional Context

I'm happy to submit a PR for this.

Something similar was reported here also: #5104

@jcesarmobile
Copy link
Member

assembleDebug is supposed to build a debug apk for all the configured flavors, isn’t it working? Maybe you have some setting that prevents it from working?

@sandor-biro
Copy link
Contributor Author

I understand all flavors are supposed to be built at every save. Is this what you meant?

My question is: what if there are more than 10 flavors? All of them will (i.e. should) be built into the .apk at every save?

@jcesarmobile
Copy link
Member

No at every save, as you are using live reload the native app is not rebuilt on every save, just the web part and it reloads the WebView without rebuilding the native part.

@adrianpunkt
Copy link

Our use case here is to build one flavor at a time since we do some additional configuration for that flavor. The build process fails since it cannot build all of them at the same time. Since the capacitor.config.ts includes one flavor, it would make sense to build only one, hence the need to call assembleFlavorDebug instead of assembleDebug which builds all:

const config: CapacitorConfig = {
 ...
  },
  ios: {
    scheme: 'XCODE_SCHEME',
  },
  android: {
    flavor: 'ANDROID_FLAVOR'
  }
};

@adrianpunkt
Copy link

For livereload, it also doesn't make sense to build multiple flavors at once.

@carlpoole
Copy link
Member

Would it make sense to just build the flavor specified in the config, such that the control of what gets built is dictated by the config, or is there a benefit to also making it configurable in the live reload command?

@adrianpunkt
Copy link

I think using what's in config is a good start. Adding that to the livereload is also a nice feature.

For example we have a gulp task that will update the capacitor.config.ts before the livereload command, and having a param would improve the process and not require a gulp task for this.

@jcesarmobile
Copy link
Member

--livereload is an option on ionic CLI, so should be done/requested there

@adrianpunkt
Copy link

Fair enough, the limitation still exists in Capacitor, so the CLI update will probably not be enough

@jcesarmobile
Copy link
Member

closing since the linked PR is merged

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 10, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants