Teach the flutter tool how to find android output files if the flavor contains uppercase letters #66687
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.
Description
This changes the name of the generated output files on android in case a flavor with uppercase letters is used.
Previously, the lowercased flavor name would be used for the apk/aab file. Now, the flavor name is used as-is.
Example: when adding a flavor with the name "aB" to the flutter template project, the name of the generated .aab file is now
app-aB-release.aab
instead ofapp-ab-release.aab
Because of calling .toLowerCase() on the flavor name, the generated apk/aab files would not be found after the Gradle build for users that use a case sensitive file system (typically Linux, but not Windows or Mac OS), and they would get an error message
because the flutter tool looks for a file with the real flavor name in its name, not the lowercased flavor name.
See https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/gradle.dart#L900
Related Issues
fixes #24106 , particularly #24106 (comment)
Tests
I did not add tests. Since this is a change in the gradle file for the android build process, I don't know how I would add a test for this. If tests are required, I would appreciate a pointer on how and where to add them.
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].
This should not be a breaking change.
If one does not use uppercase letters in flavor names, nothing changes.
Otherwise, for Windows and Mac, this name of the generated file apk will be different, however, since the file systems of these operating systems are not case sensitive, this should not cause problems.
On Linux, this should also not be a breaking change, since using a flavor name with uppercase letters caused the build to fail anyway previously.
Alternatives
If using upper case letters in the output files is not desired, we could also fix the expected file names in
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/gradle.dart to use the lower case flavor names.
see #65768