[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? https://github.com/flutter/flutter/issues/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.
This commit is contained in:
parent
31c4875c7a
commit
b02643b7d9
@ -698,14 +698,15 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
||||
return false;
|
||||
}
|
||||
|
||||
// As long as libflutter.so.sym is present for at least one architecture,
|
||||
// As long as libflutter.so.sym or libflutter.so.dbg is present for at least one architecture,
|
||||
// assume AGP succeeded in stripping.
|
||||
if (result.stdout.contains('libflutter.so.sym')) {
|
||||
if (result.stdout.contains('libflutter.so.sym') ||
|
||||
result.stdout.contains('libflutter.so.dbg')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.printTrace(
|
||||
'libflutter.so.sym not present when checking final appbundle for debug symbols.',
|
||||
'libflutter.so.sym or libflutter.so.dbg not present when checking final appbundle for debug symbols.',
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -851,6 +851,16 @@ void main() {
|
||||
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/
|
||||
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/
|
||||
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/libflutter.so.sym
|
||||
''';
|
||||
|
||||
// Output from `<android_sdk_root>/tools/bin/apkanalyzer files list <aab>`
|
||||
// on an aab containing the debug info and symbol tables.
|
||||
const String apkanalyzerOutputWithDebugInfoAndSymFiles =
|
||||
apkanalyzerOutputWithoutSymFiles +
|
||||
r'''
|
||||
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/
|
||||
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/
|
||||
/BUNDLE-METADATA/com.android.tools.build.debugsymbols/arm64-v8a/libflutter.so.dbg
|
||||
''';
|
||||
|
||||
void createSharedGradleFiles() {
|
||||
@ -942,6 +952,71 @@ void main() {
|
||||
overrides: <Type, Generator>{AndroidStudio: () => FakeAndroidStudio()},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'build succeeds when debug info and symbol tables present for at least one architecture',
|
||||
() async {
|
||||
final AndroidGradleBuilder builder = AndroidGradleBuilder(
|
||||
java: FakeJava(),
|
||||
logger: logger,
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
artifacts: Artifacts.test(),
|
||||
analytics: fakeAnalytics,
|
||||
gradleUtils: FakeGradleUtils(),
|
||||
platform: FakePlatform(environment: <String, String>{'HOME': '/home'}),
|
||||
androidStudio: FakeAndroidStudio(),
|
||||
);
|
||||
processManager.addCommand(
|
||||
FakeCommand(command: List<String>.of(commonCommandPortion)..add('bundleRelease')),
|
||||
);
|
||||
|
||||
createSharedGradleFiles();
|
||||
final File aabFile = createAabFile(BuildMode.release);
|
||||
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk()!;
|
||||
|
||||
processManager.addCommand(
|
||||
FakeCommand(
|
||||
command: <String>[
|
||||
sdk.getCmdlineToolsPath(apkAnalyzerBinaryName)!,
|
||||
'files',
|
||||
'list',
|
||||
aabFile.path,
|
||||
],
|
||||
stdout: apkanalyzerOutputWithDebugInfoAndSymFiles,
|
||||
),
|
||||
);
|
||||
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(
|
||||
fileSystem.currentDirectory,
|
||||
);
|
||||
project.android.appManifestFile
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(minimalV2EmbeddingManifest);
|
||||
|
||||
await builder.buildGradleApp(
|
||||
project: project,
|
||||
androidBuildInfo: const AndroidBuildInfo(
|
||||
BuildInfo(
|
||||
BuildMode.release,
|
||||
null,
|
||||
treeShakeIcons: false,
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
),
|
||||
targetArchs: <AndroidArch>[
|
||||
AndroidArch.arm64_v8a,
|
||||
AndroidArch.armeabi_v7a,
|
||||
AndroidArch.x86_64,
|
||||
],
|
||||
),
|
||||
target: 'lib/main.dart',
|
||||
isBuildingBundle: true,
|
||||
configOnly: false,
|
||||
localGradleErrors: <GradleHandledError>[],
|
||||
);
|
||||
},
|
||||
overrides: <Type, Generator>{AndroidStudio: () => FakeAndroidStudio()},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'building a debug aab does not invoke apkanalyzer',
|
||||
() async {
|
||||
|
Loading…
x
Reference in New Issue
Block a user