aws-amplify / aws-amplify/amplify-cli

Support env-specific Android `ResDir` configuration

Open
#12,718 1 comment 1 reaction 0 assignees View on GitHub
feature-request p4 platform platform-config
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Is this feature request related to a new or existing Amplify category?

auth, api

### Is this related to another service?

_No response_

### Describe the feature you'd like to request

CLI should allow per-env `ResDir` configuration for Android projects. Initial post in Discord: https://discord.com/channels/705853757799399426/1102976353285968023

### Describe the solution you'd like

The CLI should better leverage Android [source sets](https://developer.android.com/build/build-variants#sourcesets) by allowing per-env `ResDir` configuration. For instance, a common setup would be a debug build that points to `dev` and a release build that points to `prod`:

|Amplify env|`ResDir`|
|-|-|
|`prod`|`app/src/main/res`|
|`dev`|`app/src/debug/res`|

Currently, only a single `ResDir` can be configured for an Android project in `project-config.json`. This is problematic, because `amplify env checkout` overrides `amplifyconfiguration.json` when switching envs. It becomes difficult to know which config currently resides in `ResDir`, especially as these files are gitignored and their changes are never staged.

Per-env `ResDir`s would allow multiple `amplifyconfiguration.json` files to coexist in the Android source and have them be automatically loaded at runtime based on the build variant (while keeping unneeded configs out of the build). It would also increase confidence that pulling Amplify changes will only affect the Amplify config for the desired Android build variant.

### Describe alternatives you've considered

Loading config at runtime [like this](https://discord.com/channels/705853757799399426/707329009574346754/789171554394308620) works, but requires manual management of config files outside of the CLI (renaming files so they aren't overridden on checkout, manually loading the desired config at runtime). Another undesirable side effect of this approach is that all configs are included in the build, instead of just the one that is needed.

### Additional context

_No response_

### Is this something that you'd be interested in working on?

- [ ] 👋 I may be able to implement this feature request

### Would this feature include a breaking change?

- [ ] ⚠️ This feature might incur a breaking change

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the CLI reads and writes project-config.json and amplifyconfiguration.json, then review the Android source-set behavior linked in the issue. Done should allow separate per-environment ResDir values, preserve the correct configuration through env checkout, and select only the configuration for the requested build variant.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, typescript
Domain
cli, mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.