Skip to content

Commit f7221fb

Browse files
authored
Bump flutter_flavorizr to published 2.5.0 (fix flavor APK build) (#158)
* Bump flutter_flavorizr to published 2.5.0 (fix flavor APK build) The Shorebird Android Tests' flavor builds fail on 3.44.1: Product Flavor playStore contains custom resource values, but the feature is disabled. The test scaffolds flavors with flutter_flavorizr pinned to a fork at a Flutter-3.29-era ref (AngeloAvv/flutter_flavorizr#291, which was never merged). The AGP that ships with 3.44.1 disables resValues by default, and the 3.29-era generator doesn't enable the build feature, so the generated project won't configure. Move to the published flutter_flavorizr ^2.5.0, which has moved well past 3.29 and generates AGP-8-compatible flavor config. Removes the stale fork pin + felangel TODO. * Pass -f to flutter_flavorizr (skip interactive prompt under CI) flutter_flavorizr 2.5.0 added an interactive 'Do you want to proceed? (Y/n)' confirmation, which throws 'No terminal attached to stdout' in CI (both Android Tests and the Smoke build). The -f/--force flag runs it non-interactively. * Pin flutter_flavorizr to 2.4.2 (Ruby xcodeproj, fixes iOS flavor archive) 2.5.0 replaced Ruby xcodeproj with dart_xcodeproj; its generated .pbxproj breaks 'flutter build ipa --no-codesign --flavor' (unsigned flavor archive demands a Development Team). All versions emit identical visible signing settings, so it's the dart_xcodeproj generation, not config — and the old fork worked precisely because it used Ruby xcodeproj. 2.4.2 is the last Ruby-xcodeproj release and still carries the 3.29/AGP-8 resValues fix that the 3.29-era fork lacked, so it should green both the Android (resValues) and Smoke (iOS flavor) builds. * Enable resValues build feature after flavorizr (fix flavored APK) There is no single flutter_flavorizr version that greens both checks: 2.5.0 fixes the AGP-8 resValues issue but its dart_xcodeproj rewrite breaks the unsigned iOS flavor archive; 2.4.2 (last Ruby-xcodeproj release) fixes iOS but predates the resValues fix. So pin 2.4.2 (iOS works) and post-fix the one thing it misses: append android.defaults.buildfeatures.resvalues=true to the generated gradle.properties so the flavored 'flutter build apk' configures under AGP 8. Wraps flavorizr rather than forking it.
1 parent 26ad1cd commit f7221fb

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

packages/shorebird_tests/test/shorebird_tests.dart

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,18 @@ extension ShorebirdProjectDirectoryOnDirectory on Directory {
240240

241241
Future<void> addProjectFlavors() async {
242242
await addPubDependency(
243-
// TODO(felangel): revert to using published version once 3.29.0 support is released.
244-
// https://github.com/AngeloAvv/flutter_flavorizr/pull/291
245-
'dev:flutter_flavorizr:{"git":{"url":"https://github.com/wjlee611/flutter_flavorizr.git","ref":"chore/temp-migrate-3-29","path":"."}}',
243+
// Published flutter_flavorizr. We previously pinned a fork for Flutter
244+
// 3.29 support (AngeloAvv/flutter_flavorizr#291, never merged); the
245+
// published package has since adopted 3.29/AGP-8 support (>=2.3.0), so
246+
// the fork is obsolete.
247+
//
248+
// Pinned to 2.4.2 (not the latest 2.5.x): 2.5.0 replaced the Ruby
249+
// xcodeproj gem with dart_xcodeproj, and its generated .pbxproj breaks
250+
// `flutter build ipa --no-codesign --flavor` (the unsigned flavor
251+
// archive demands a Development Team). 2.4.2 is the last Ruby-xcodeproj
252+
// release and matches the generation path the old fork used, while
253+
// still carrying the AGP-8 resValues fix the fork lacked.
254+
'dev:flutter_flavorizr:2.4.2',
246255
);
247256

248257
await File(
@@ -279,13 +288,30 @@ flavors:
279288
''');
280289

281290
final result = await _runFlutterCommand(
282-
['pub', 'run', 'flutter_flavorizr'],
291+
// -f/--force skips flutter_flavorizr's interactive "proceed? (Y/n)"
292+
// prompt, which throws "No terminal attached to stdout" under CI.
293+
['pub', 'run', 'flutter_flavorizr', '-f'],
283294
workingDirectory: this,
284295
);
285296
if (result.exitCode != 0) {
286297
throw Exception(
287298
'Failed to run `flutter pub run flutter_flavorizr`: ${result.stderr}');
288299
}
300+
301+
// flutter_flavorizr 2.4.2 emits per-flavor `resValue` entries in
302+
// build.gradle. AGP 8 (Flutter 3.44+) gates resValues behind an opt-in
303+
// build feature, so the flavored `flutter build apk` fails with "contains
304+
// custom resource values, but the feature is disabled" unless we enable
305+
// it. (Published flavorizr only enables this on 2.5.x, which we can't use:
306+
// 2.5.0's dart_xcodeproj rewrite breaks `flutter build ipa --no-codesign
307+
// --flavor`. So we stay on the last Ruby-xcodeproj release and toggle the
308+
// build feature ourselves.)
309+
final gradleProperties =
310+
File(path.join(this.path, 'android', 'gradle.properties'));
311+
await gradleProperties.writeAsString(
312+
'\nandroid.defaults.buildfeatures.resvalues=true\n',
313+
mode: FileMode.append,
314+
);
289315
}
290316

291317
void addShorebirdFlavors() {

0 commit comments

Comments
 (0)