Unverified Commit 91ec4393 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] handle missing null check in manifest parser (#57400)

parent 70b889a9
...@@ -565,7 +565,9 @@ class ApkManifestData { ...@@ -565,7 +565,9 @@ class ApkManifestData {
} }
final _Element application = manifest.firstElement('application'); final _Element application = manifest.firstElement('application');
assert(application != null); if (application == null) {
return null;
}
final Iterable<_Element> activities = application.allElements('activity'); final Iterable<_Element> activities = application.allElements('activity');
......
...@@ -206,6 +206,12 @@ void main() { ...@@ -206,6 +206,12 @@ void main() {
expect(data.packageName, 'io.flutter.examples.hello_world'); expect(data.packageName, 'io.flutter.examples.hello_world');
expect(data.launchableActivityName, 'io.flutter.examples.hello_world.MainActivity'); expect(data.launchableActivityName, 'io.flutter.examples.hello_world.MainActivity');
}, overrides: noColorTerminalOverride); }, overrides: noColorTerminalOverride);
testUsingContext('Parses manifest with missing application tag', () async {
final ApkManifestData data = ApkManifestData.parseFromXmlDump(_aaptDataWithoutApplication);
expect(data, isNull);
});
}); });
group('PrebuiltIOSApp', () { group('PrebuiltIOSApp', () {
...@@ -644,6 +650,26 @@ N: android=http://schemas.android.com/apk/res/android ...@@ -644,6 +650,26 @@ N: android=http://schemas.android.com/apk/res/android
A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER") A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
'''; ''';
const String _aaptDataWithoutApplication = '''
N: android=http://schemas.android.com/apk/res/android
N: dist=http://schemas.android.com/apk/distribution
E: manifest (line=7)
A: android:versionCode(0x0101021b)=(type 0x10)0x1
A: android:versionName(0x0101021c)="1.0" (Raw: "1.0")
A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
A: package="io.flutter.examples.hello_world" (Raw: "io.flutter.examples.hello_world")
A: platformBuildVersionCode=(type 0x10)0x1
A: platformBuildVersionName=(type 0x4)0x3f800000
E: uses-sdk (line=13)
A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
E: dist:module (line=17)
A: dist:instant=(type 0x12)0xffffffff
E: uses-permission (line=24)
A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
''';
class MockPlistUtils extends Mock implements PlistParser { class MockPlistUtils extends Mock implements PlistParser {
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment