-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Xamarin.Android.Build.Tasks] Feature for excluding Kotlin-related files from apps #7356
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…les from apps Fixes dotnet#6920 Add a new ItemGroup `AndroidPackagingOptionsExclude` to the common targets. This ItemGroup will contain a set of RegEx compatible patterns which will be used to exlcude certain files from the final apk/aab. The patterns will need to be Url encoded so that MSBuild does not try to interpret them. The main purpose of this is to allow us to exclude certain Kotlin meta-data files from the final package. These files seem to be excluded by gradle so we should do the same.
dellis1972
requested review from
jonathanpeppers and
jonpryor
as code owners
September 7, 2022 14:39
We will need this too https://github.com/xamarin/monodroid/pull/1265 |
jonathanpeppers
approved these changes
Sep 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, looks good if CI is green.
jonpryor
reviewed
Sep 9, 2022
jonpryor
reviewed
Sep 9, 2022
jonathanpeppers
approved these changes
Sep 9, 2022
Co-authored-by: Jonathan Peppers <[email protected]>
Fixes: https://github.com/xamarin/xamarin-android/issues/6920
Certainly NuGet packages pull in Kotlin-related artifacts which
aren't required at runtime. These artifacts contribute to `.apk`
package size.
The [recommendation for native Android developers][0] is to
explicitly exclude these artifacts by using `packagingOptions`:
packagingOptions {
exclude 'DebugProbesKt.bin'
}
Xamarin.Android and .NET SDK for Android developers don't use Gradle,
so the above snippet is not useful.
Add support for a new `@(AndroidPackagingOptionsExclude)` item group.
This contains a "search pattern" a'la the `searchPattern` parameter
of [`Directory.EnumerateFiles(path, searchPattern)`][1], in which:
* `*` matches 0 or more characters
* `?` matches 1 character.
The default items within `@(AndroidPackagingOptionsExclude)` are:
* `DebugProbesKt.bin`
* `*.kotlin_*`
Files which match the search patterns within
`@(AndroidPackagingOptionsExclude)` are *excluded* from `.aab` and
`.apk` files, reducing app size.
[0]: https://github.com/Kotlin/kotlinx.coroutines/issues/2274
[1]: https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.enumeratefiles?view=net-6.0#system-io-directory-enumeratefiles(system-string-system-string) |
grendello
added a commit
to grendello/xamarin-android
that referenced
this pull request
Sep 14, 2022
* main: [Xamarin.Android.Build.Tasks] Add AndroidPackagingOptionsExclude (dotnet#7356) [linker] preserve Java interfaces on non-bound Java types (dotnet#7204) [Xamarin.Android.Build.Tasks] AndroidLinkResources and Styleables (dotnet#7306)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #6920
Add a new ItemGroup
AndroidPackagingOptionsExclude
to the common targets. This ItemGroup will contain a set of RegEx compatible patterns which will be used to exclude certain files from the final apk/aab.The patterns will need to be Url encoded so that MSBuild does not try to interpret them.
The main purpose of this is to allow us to exclude certain Kotlin meta-data files from the final package. These files seem to be excluded by gradle so we should do the same.