@@ -55,6 +55,73 @@ void main() {
5555 ).path).createSync (recursive: true );
5656 });
5757
58+ testUsingContext ('correct debug filename in module projects' , () async {
59+ const String aaptPath = 'aaptPath' ;
60+ final File apkFile = globals.fs.file ('app-debug.apk' );
61+ final FakeAndroidSdkVersion sdkVersion = FakeAndroidSdkVersion ();
62+ sdkVersion.aaptPath = aaptPath;
63+ sdk.latestVersion = sdkVersion;
64+ sdk.platformToolsAvailable = true ;
65+ sdk.licensesAvailable = false ;
66+
67+ fakeProcessManager.addCommand (
68+ FakeCommand (
69+ command: < String > [
70+ aaptPath,
71+ 'dump' ,
72+ 'xmltree' ,
73+ apkFile.path,
74+ 'AndroidManifest.xml' ,
75+ ],
76+ stdout: _aaptDataWithDefaultEnabledAndMainLauncherActivity
77+ )
78+ );
79+
80+ fakeProcessManager.addCommand (
81+ FakeCommand (
82+ command: < String > [
83+ aaptPath,
84+ 'dump' ,
85+ 'xmltree' ,
86+ fs.path.join ('module_project' , 'build' , 'host' , 'outputs' , 'apk' , 'debug' , 'app-debug.apk' ),
87+ 'AndroidManifest.xml' ,
88+ ],
89+ stdout: _aaptDataWithDefaultEnabledAndMainLauncherActivity
90+ )
91+ );
92+
93+ await ApplicationPackageFactory .instance! .getPackageForPlatform (
94+ TargetPlatform .android_arm,
95+ applicationBinary: apkFile,
96+ );
97+ final BufferLogger logger = BufferLogger .test ();
98+ final FlutterProject project = await aModuleProject ();
99+ project.android.hostAppGradleRoot.childFile ('build.gradle' ).createSync (recursive: true );
100+ final File appGradle = project.android.hostAppGradleRoot.childFile (
101+ fs.path.join ('app' , 'build.gradle' ));
102+ appGradle.createSync (recursive: true );
103+ appGradle.writeAsStringSync ("def flutterPluginVersion = 'managed'" );
104+ final File apkDebugFile = project.directory
105+ .childDirectory ('build' )
106+ .childDirectory ('host' )
107+ .childDirectory ('outputs' )
108+ .childDirectory ('apk' )
109+ .childDirectory ('debug' )
110+ .childFile ('app-debug.apk' );
111+ apkDebugFile.createSync (recursive: true );
112+ final AndroidApk ? androidApk = await AndroidApk .fromAndroidProject (
113+ project.android,
114+ androidSdk: sdk,
115+ processManager: fakeProcessManager,
116+ userMessages: UserMessages (),
117+ processUtils: ProcessUtils (processManager: fakeProcessManager, logger: logger),
118+ logger: logger,
119+ fileSystem: fs,
120+ buildInfo: const BuildInfo (BuildMode .debug, null , treeShakeIcons: false ),
121+ );
122+ expect (androidApk, isNotNull);
123+ }, overrides: overrides);
124+
58125 testUsingContext ('Licenses not available, platform and buildtools available, apk exists' , () async {
59126 const String aaptPath = 'aaptPath' ;
60127 final File apkFile = globals.fs.file ('app-debug.apk' );
@@ -895,3 +962,19 @@ class FakeAndroidSdkVersion extends Fake implements AndroidSdkVersion {
895962 @override
896963 late String aaptPath;
897964}
965+
966+ Future <FlutterProject > aModuleProject () async {
967+ final Directory directory = globals.fs.directory ('module_project' );
968+ directory
969+ .childDirectory ('.dart_tool' )
970+ .childFile ('package_config.json' )
971+ ..createSync (recursive: true )
972+ ..writeAsStringSync ('{"configVersion":2,"packages":[]}' );
973+ directory.childFile ('pubspec.yaml' ).writeAsStringSync ('''
974+ name: my_module
975+ flutter:
976+ module:
977+ androidPackage: com.example
978+ ''' );
979+ return FlutterProject .fromDirectory (directory);
980+ }
0 commit comments