Skip to content

Commit b02643b

Browse files
[CP-stable]fix: add the missing type of debug metadata (#170003)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #169252 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples Fixes a build failure on Android for app bundles when setting debug symbol level to `FULL` and using release mode. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Flutter fails to build an AAB in release mode. ### Workaround: Is there a workaround for this issue? No, besides not using this symbol level. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? This linked issue has easy to follow repro steps for the original issue, which also function as validation steps that the issue is fixed.
1 parent 31c4875 commit b02643b

File tree

2 files changed

+79
-3
lines changed

2 files changed

+79
-3
lines changed

packages/flutter_tools/lib/src/android/gradle.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,15 @@ class AndroidGradleBuilder implements AndroidBuilder {
698698
return false;
699699
}
700700

701-
// As long as libflutter.so.sym is present for at least one architecture,
701+
// As long as libflutter.so.sym or libflutter.so.dbg is present for at least one architecture,
702702
// assume AGP succeeded in stripping.
703-
if (result.stdout.contains('libflutter.so.sym')) {
703+
if (result.stdout.contains('libflutter.so.sym') ||
704+
result.stdout.contains('libflutter.so.dbg')) {
704705
return true;
705706
}
706707

707708
_logger.printTrace(
708-
'libflutter.so.sym not present when checking final appbundle for debug symbols.',
709+
'libflutter.so.sym or libflutter.so.dbg not present when checking final appbundle for debug symbols.',
709710
);
710711
return false;
711712
}

packages/flutter_tools/test/general.shard/android/android_gradle_builder_test.dart

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,16 @@ void main() {
851851
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/
852852
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/
853853
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/libflutter.so.sym
854+
''';
855+
856+
// Output from `<android_sdk_root>/tools/bin/apkanalyzer files list <aab>`
857+
// on an aab containing the debug info and symbol tables.
858+
const String apkanalyzerOutputWithDebugInfoAndSymFiles =
859+
apkanalyzerOutputWithoutSymFiles +
860+
r'''
861+
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/
862+
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/
863+
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/libflutter.so.dbg
854864
''';
855865

856866
void createSharedGradleFiles() {
@@ -942,6 +952,71 @@ void main() {
942952
overrides: <Type, Generator>{AndroidStudio: () => FakeAndroidStudio()},
943953
);
944954

955+
testUsingContext(
956+
'build succeeds when debug info and symbol tables present for at least one architecture',
957+
() async {
958+
final AndroidGradleBuilder builder = AndroidGradleBuilder(
959+
java: FakeJava(),
960+
logger: logger,
961+
processManager: processManager,
962+
fileSystem: fileSystem,
963+
artifacts: Artifacts.test(),
964+
analytics: fakeAnalytics,
965+
gradleUtils: FakeGradleUtils(),
966+
platform: FakePlatform(environment: <String, String>{'HOME': '/home'}),
967+
androidStudio: FakeAndroidStudio(),
968+
);
969+
processManager.addCommand(
970+
FakeCommand(command: List<String>.of(commonCommandPortion)..add('bundleRelease')),
971+
);
972+
973+
createSharedGradleFiles();
974+
final File aabFile = createAabFile(BuildMode.release);
975+
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
976+
977+
processManager.addCommand(
978+
FakeCommand(
979+
command: <String>[
980+
sdk.getCmdlineToolsPath(apkAnalyzerBinaryName)!,
981+
'files',
982+
'list',
983+
aabFile.path,
984+
],
985+
stdout: apkanalyzerOutputWithDebugInfoAndSymFiles,
986+
),
987+
);
988+
989+
final FlutterProject project = FlutterProject.fromDirectoryTest(
990+
fileSystem.currentDirectory,
991+
);
992+
project.android.appManifestFile
993+
..createSync(recursive: true)
994+
..writeAsStringSync(minimalV2EmbeddingManifest);
995+
996+
await builder.buildGradleApp(
997+
project: project,
998+
androidBuildInfo: const AndroidBuildInfo(
999+
BuildInfo(
1000+
BuildMode.release,
1001+
null,
1002+
treeShakeIcons: false,
1003+
packageConfigPath: '.dart_tool/package_config.json',
1004+
),
1005+
targetArchs: <AndroidArch>[
1006+
AndroidArch.arm64_v8a,
1007+
AndroidArch.armeabi_v7a,
1008+
AndroidArch.x86_64,
1009+
],
1010+
),
1011+
target: 'lib/main.dart',
1012+
isBuildingBundle: true,
1013+
configOnly: false,
1014+
localGradleErrors: <GradleHandledError>[],
1015+
);
1016+
},
1017+
overrides: <Type, Generator>{AndroidStudio: () => FakeAndroidStudio()},
1018+
);
1019+
9451020
testUsingContext(
9461021
'building a debug aab does not invoke apkanalyzer',
9471022
() async {

0 commit comments

Comments
 (0)