Skip to content

Exclusion of Kotlin-related files (AndroidPackagingOptionsExclude) does not work #7902

@tranb3r

Description

@tranb3r

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

VS 2022 17.5.0

Description

When building a net7.0-android application, kotlin-related files are supposed to be excluded from the final aab or apk.

This is done thanks to AndroidPackagingOptionsExclude as explained here:
https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/building-apps/build-items.md#androidpackagingoptionsexclude

However, in the current version of XA, it does not work.
The bug is probably because the continue statement for file exclusion is in a nested loop:
https://github.com/xamarin/xamarin-android/blob/8102a8bb7c73991b13f7ac4adc01a412a89ea289/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs#L260

Could you please fix it?

Steps to Reproduce

  1. dotnet new maui
  2. dotnet build -c Release -f net7.0-android
  3. open aab or apk and look for kotlin folder containing *.kotlin_* files

Did you find any workaround?

No :/

Relevant log output

Here is the log I get during build of my app:

Ignoring jar entry 'kotlin/ArithmeticException.kotlinmetadata' from 'org.jetbrains.kotlin.kotlin-stdlib-common-1.8.0.jar'. Filename matched the exclude pattern '.*.kotlin.*'.
Adding kotlin/ArithmeticException.kotlin_metadata from C:\Nuget\xamarin.kotlin.stdlib.common\1.8.0.1\jar\org.jetbrains.kotlin.kotlin-stdlib-common-1.8.0.jar as the archive file is out of date.

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions