-
Notifications
You must be signed in to change notification settings - Fork 565
Description
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS2022 17.7.5
Description
We have a large former Xamarin Android application which we converted to .NET7.
The application is using some bindings which are using Kotlin and kotlin-reflect
The application works in DEBUG mode but when it gets packaged in RELEASE mode the app crashes on Android.
The exception in ADB log is :
java.lang.AssertionError: Built-in class kotlin.Any is not found at
kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns$3.invoke(KotlinBuiltIns.java:93)
After digging a lot around we discovered that debug APK and release APK have different content regarding kotlin modules.
This lead us to the csproj ItemGroup element AndroidPackagingOptionsExclude which was added with this PR : 7356
We played around with the element and tried to remove it with
<ItemGroup>
<AndroidPackagingOptionsExclude Remove="$([MSBuild]::Escape('*.kotlin_*'))" />
</ItemGroup>
in the main project. But our remove was ignored during build and the exclusion was still happening.
So we modified the Xamarin.Android.Common.targets file directly by commenting out the wildcard. This resulted into a working application again.
So we can confirm so far that the wildcard '.kotlin_ may be to restrictive and should be removed from the target file. The filter is removing the files *kotlin_builtins which are used by the package kotlin.reflect.jvm
Regarding the remove of the AndroidPackagingOptionsExclude in our csproj : Are we doing something wrong with the itemgroup above ?
Steps to Reproduce
- Build an android app that is using kotlin-reflect
- Build in release mode
Did you find any workaround?
Modifying xamarin.android.common.targets
<ItemGroup>
<AndroidPackagingOptionsExclude Include="DebugProbesKt.bin" />
<!--<AndroidPackagingOptionsExclude Include="$([MSBuild]::Escape('*.kotlin_*'))" />-->
</ItemGroup>
Relevant log output
No response