Skip to content

Feature for excluding Kotlin-related files from apps #6920

@jonathanpeppers

Description

@jonathanpeppers

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6

Description

dotnet new maui includes a lot of "weird" Kotlin files like:

image

DebugProbesKt.bin, they actually recommend:

packagingOptions {
  exclude "DebugProbesKt.bin"
}

See: Kotlin/kotlinx.coroutines#2274

The kotlin folder above has lot of *.kotlin_metadata files that is apparently only used if Kotlin reflection is used at runtime:

https://youtrack.jetbrains.com/issue/KT-9770

Proposal

Add a new item group to mirror the gradle feature above. I don't think we have an equivalent in Xamarin.Android or .NET 6?

Maybe our MSBuild targets can define something like:

<ItemGroup>
  <AndroidPackagingOptionsExclude Include="DebugProbesKt.bin" />
  <AndroidPackagingOptionsExclude Include="**/*.kotlin_*" />
</ItemGroup>

NOTE: I think we'd might have to escape the * with url encoding.

In the rare case where a customer needs some of these files, they could clear them in their .csproj as needed:

<ItemGroup>
  <AndroidPackagingOptionsExclude Remove="@(AndroidPackagingOptionsExclude)" />
</ItemGroup>

Steps to Reproduce

  1. dotnet new maui
  2. dotnet build -c Release -f net6.0-android

Then look at the .apk file.

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.enhancementProposed change to current functionality.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions