applyManifest static method

void applyManifest(
  1. ProjectConfig config
)

Rewrites android/app/src/main/AndroidManifest.xml so the app label reads from the per-flavor app_name string resource (defined via resValue in apply) instead of a hard-coded value. Without this, the resValue entries are inert and every flavor shows the same name.

No-op (with a warning) when there are no flavors or the manifest is missing. Idempotent. Throws StateError if the manifest exists but has no android:label attribute to edit.

Implementation

static void applyManifest(ProjectConfig config) {
  if (!config.hasFlavors) return;

  final manifest = File(p.join(config.projectPath, 'android', 'app', 'src',
      'main', 'AndroidManifest.xml'));
  if (!manifest.existsSync()) {
    Logger.warn(
      'No AndroidManifest.xml found — skipping per-flavor app label wiring.',
    );
    return;
  }

  final original = manifest.readAsStringSync();
  final updated = setAppLabelToResource(original);
  if (updated == original) return; // already wired
  manifest.writeAsStringSync(updated);
  Logger.info('Wired AndroidManifest.xml label to @string/app_name');
}