-
Notifications
You must be signed in to change notification settings - Fork 218
feat(shorebird_cli): prepare for Flutter 3.44 libapp.so strip handover #3758
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0938fdb
feat(shorebird_cli): prepare for Flutter 3.44 libapp.so strip handover
bdero a6e7294
style(shorebird_cli): apply dart format to legacy_keep_debug_symbols_…
bdero f742aa9
test: cover new branches in patch_command and android_releaser obfusc…
bdero fc7151b
refactor(shorebird_cli): extract shouldPreStripLibappInGenSnapshot he…
bdero 8c429bd
docs(shorebird_cli): drop _shorebird tracking-issue refs from public …
bdero a44d4a6
feat(artifact_proxy): allow Flutter 3.44+ iOS USB dependency URLs
bdero 34d289d
fix(shorebird_cli): drop unused pub_semver import in patch_command_test
bdero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
packages/shorebird_cli/lib/src/validators/legacy_keep_debug_symbols_validator.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import 'dart:io'; | ||
|
|
||
| import 'package:path/path.dart' as p; | ||
| import 'package:shorebird_cli/src/flutter_version_constraints.dart'; | ||
| import 'package:shorebird_cli/src/shorebird_env.dart'; | ||
| import 'package:shorebird_cli/src/shorebird_flutter.dart'; | ||
| import 'package:shorebird_cli/src/validators/validators.dart'; | ||
|
|
||
| /// Warns when `android/app/build.gradle.kts` (or its Groovy sibling) contains | ||
| /// a legacy `packaging.jniLibs.keepDebugSymbols.add("**/libapp.so")` line on | ||
| /// projects that target Flutter 3.44 or newer. | ||
| /// | ||
| /// Background: | ||
| /// | ||
| /// Upstream Flutter PR https://github.com/flutter/flutter/pull/181275 (merged | ||
| /// 2026-01-26, first shipped in 3.44) inverted the responsibility for | ||
| /// stripping `libapp.so`. Before 3.44 Flutter stripped the AOT shared library | ||
| /// itself, so users (and the e2e test fixture) added the AGP-level | ||
| /// `keepDebugSymbols` exclusion to keep `libapp.so` byte-stable for Shorebird | ||
| /// patch diffing. From 3.44 onward, Flutter expects the Android Gradle Plugin | ||
| /// (AGP) to strip the library and produce the matching `libapp.so.sym` | ||
| /// companion in the AAB's BUNDLE-METADATA, and flutter_tools adds a | ||
| /// post-build verification that fatal-errors when that companion is missing. | ||
| /// | ||
| /// The legacy line tells AGP to skip stripping `libapp.so`, which prevents | ||
| /// the `.sym` from being produced and causes the new verification to fail. | ||
| /// On 3.44+ the line is unnecessary as well as actively harmful, so we surface | ||
| /// a warning that points the user at the exact file and substring to remove. | ||
| /// | ||
| /// On older Flutter versions the line is still appropriate and this validator | ||
| /// is a no-op. | ||
| class LegacyKeepDebugSymbolsValidator extends Validator { | ||
| /// The substring we treat as a match. Catches `add(...)` and `+=` forms, | ||
| /// single-quoted and double-quoted, with arbitrary whitespace around the | ||
| /// `(` or `+=`, since users may have hand-edited the line. | ||
| static final _legacyKeepDebugSymbolsPattern = RegExp( | ||
| r'''keepDebugSymbols\s*(?:\.add\s*\(|\+=)\s*['"][^'"]*\*\*/libapp\.so['"]''', | ||
| ); | ||
|
|
||
| @override | ||
| String get description => | ||
| 'android/app/build.gradle(.kts) does not contain a legacy ' | ||
| 'keepDebugSymbols line for libapp.so'; | ||
|
|
||
| @override | ||
| bool canRunInCurrentContext() { | ||
| if (_androidAppDirectory == null) return false; | ||
| return _gradleFiles.any((f) => f.existsSync()); | ||
| } | ||
|
|
||
| // coverage:ignore-start | ||
| @override | ||
| String? get incorrectContextMessage => | ||
| 'No android/app directory was found, so this validator does not apply.'; | ||
| // coverage:ignore-end | ||
|
|
||
| @override | ||
| Future<List<ValidationIssue>> validate() async { | ||
| final flutterRevision = shorebirdEnv.flutterRevision; | ||
| final flutterVersion = await shorebirdFlutter.resolveFlutterVersion( | ||
| flutterRevision, | ||
| ); | ||
| final agpStripsLibapp = libappStrippedByAgpConstraint.isSatisfiedBy( | ||
| // Treat unknown versions as satisfying the constraint so users who | ||
| // are pinned to a development revision (where resolveFlutterVersion | ||
| // returns null) still get the migration nudge. False positives on | ||
| // unrelated dev branches are preferable to silently missing a real | ||
| // breakage on the upgrade path. | ||
| version: flutterVersion ?? libappStrippedByAgpConstraint.minVersion, | ||
| revision: flutterRevision, | ||
| ); | ||
| if (!agpStripsLibapp) return []; | ||
|
|
||
| final issues = <ValidationIssue>[]; | ||
| for (final gradleFile in _gradleFiles) { | ||
| if (!gradleFile.existsSync()) continue; | ||
| final contents = gradleFile.readAsStringSync(); | ||
| if (!_legacyKeepDebugSymbolsPattern.hasMatch(contents)) continue; | ||
| final relativePath = p.relative( | ||
| gradleFile.path, | ||
| from: shorebirdEnv.getFlutterProjectRoot()!.path, | ||
| ); | ||
| issues.add( | ||
| ValidationIssue( | ||
| severity: ValidationIssueSeverity.warning, | ||
| message: | ||
| '$relativePath contains a legacy ' | ||
| '`packaging.jniLibs.keepDebugSymbols.add("**/libapp.so")` ' | ||
| 'line. Flutter 3.44 (PR flutter/flutter#181275) requires ' | ||
| 'AGP to strip libapp.so and emit a `libapp.so.sym` ' | ||
| 'companion. The legacy line blocks AGP from stripping, ' | ||
| 'which causes builds to fail or skips Play Console crash ' | ||
| 'symbols for Dart code. Remove the line.', | ||
| ), | ||
| ); | ||
| } | ||
| return issues; | ||
| } | ||
|
|
||
| Directory? get _androidAppDirectory { | ||
| final root = shorebirdEnv.getFlutterProjectRoot(); | ||
| if (root == null) return null; | ||
| return Directory(p.join(root.path, 'android', 'app')); | ||
| } | ||
|
|
||
| List<File> get _gradleFiles { | ||
| final appDir = _androidAppDirectory; | ||
| if (appDir == null) return const []; | ||
| return [ | ||
| File(p.join(appDir.path, 'build.gradle.kts')), | ||
| File(p.join(appDir.path, 'build.gradle')), | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe vanilla Flutter users will also run into this same surprise opaque build failure, and their AI agents will also flail around for an hours investigating. So considering possibly upstreaming something to Flutter doctor.