Skip to content

Kotlin issue when building the application #8209

Closed

Description

@jingliancui

Android application type

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

Affected platform version

VSMac 17.6.1 (build 452)

Description

MAUI App build error after add this nuget package

mauibuildlog.txt

DatePickerSampleApp.zip is the code of Forms and MAUI

Other info:
Xamarin.Forms project is fine to build

Steps to Reproduce

1.Unzip the zip file
2.open the mauisampleapp using vs for Mac
3.build the sln,
4.errors show

Did you find any workaround?

no

Relevant log output

/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): warning XA4214: The managed type `Kotlin.IO.Path.IExperimentalPathApi` exists in multiple assemblies: Xamarin.Kotlin.StdLib, Xamarin.Kotlin.StdLib.Jdk7. Please refactor the managed type names in these assemblies so that they are not identical.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): warning XA4214: References to the type `Kotlin.IO.Path.IExperimentalPathApi` will refer to `Kotlin.IO.Path.IExperimentalPathApi, Xamarin.Kotlin.StdLib`.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): warning XA4214: The managed type `Kotlin.IO.Path.IFileVisitorBuilder` exists in multiple assemblies: Xamarin.Kotlin.StdLib, Xamarin.Kotlin.StdLib.Jdk7. Please refactor the managed type names in these assemblies so that they are not identical.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): warning XA4214: References to the type `Kotlin.IO.Path.IFileVisitorBuilder` will refer to `Kotlin.IO.Path.IFileVisitorBuilder, Xamarin.Kotlin.StdLib`.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): error XA4215: The Java type `kotlin.io.path.ExperimentalPathApi` is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): error XA4215:   `kotlin.io.path.ExperimentalPathApi` generated by: Kotlin.IO.Path.IExperimentalPathApi, Xamarin.Kotlin.StdLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): error XA4215:   `kotlin.io.path.ExperimentalPathApi` generated by: Kotlin.IO.Path.IExperimentalPathApi, Xamarin.Kotlin.StdLib.Jdk7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): error XA4215: The Java type `kotlin.io.path.FileVisitorBuilder` is generated by more than one managed type. Please change the [Register] attribute so that the same Java type is not emitted.
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): error XA4215:   `kotlin.io.path.FileVisitorBuilder` generated by: Kotlin.IO.Path.IFileVisitorBuilder, Xamarin.Kotlin.StdLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
/usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.68/tools/Xamarin.Android.Common.targets(1476,3): error XA4215:   `kotlin.io.path.FileVisitorBuilder` generated by: Kotlin.IO.Path.IFileVisitorBuilder, Xamarin.Kotlin.StdLib.Jdk7, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
    4 Warning(s)
    6 Error(s)

Activity

  1. added
    Area: App+Library Build
    needs-triage
    on Jul 22, 2023
  2. jonathanpeppers commented on Jul 24, 2023

    @jonathanpeppers
    Member

    @jpobst @moljac is kotlin.io.path.ExperimentalPathApi one of the types that Google moved around recently?

  3. jpobst commented on Jul 24, 2023

    @jpobst
    Contributor

    I get a different error locally:

    (0,1): error JAVA0000: Error in C:\.tools\.nuget\packages\xamarin.androidx.annotation\1.5.0.2\buildTransitive\net6.0-android31.0\..\..\jar\androidx.annotation.annotation.jar:androidx/annotation/AnimRes.class:
    Type androidx.annotation.AnimRes is defined multiple times: C:\.tools\.nuget\packages\xamarin.androidx.annotation\1.5.0.2\buildTransitive\net6.0-android31.0\..\..\jar\androidx.annotation.annotation.jar:androidx/annotation/AnimRes.class, obj\Debug\net8.0-android\lp\145\jl\libs\54FB89168AC57954.jar:androidx/annotation/AnimRes.class
    ...
    Directory 'obj\Debug\net8.0-android\lp\145' is from 'DateTimePickerBinding.aar'. [C:\Users\jopobst\Desktop\kotlin-dupe-test\kotlin-dupe-test.csproj]
    

    Looking at the XamarinLibrary.Net.Android.Loper7.DateTimePicker package, it would appear to include several AndroidX .aar files in it:

    image

    image

    Likely these were referenced via a .jar/.aar instead of a PackageReference?

    They should not have been included in the XamarinLibrary.Net.Android.Loper7.DateTimePicker package.

  4. removed
    needs-triage
    on Jul 24, 2023
  5. moljac commented on Jul 25, 2023

    @moljac
    Contributor

    @jpobst @moljac is kotlin.io.path.ExperimentalPathApi one of the types that Google moved around recently?

    Not Google, but JetBrains in this case.

    Related:

    #7699

    Workaround for Kotlin errors is to add

    		<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.9.0.1" />
    

    Further errors cannot be resolved because of embedded aars (see previous comment #8209 (comment))

  6. jingliancui commented on Jul 26, 2023

    @jingliancui
    Author

    I think there may some issue on binding Or application.
    Let me share the binding code later.

  7. added
    need-info
    on Aug 1, 2023
  8. microsoft-github-policy-service commented on Aug 1, 2023

    @microsoft-github-policy-service
    Contributor

    Hi @jingliancui. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

  9. jingliancui commented on Aug 2, 2023

    @jingliancui
    Author

    DateTimePickerBinding.zip
    @jpobst please take a look.
    after using vs Mac to build it, it will generates 2 aars file as the image you send days ago.

  10. added
    need-attention
    and removed
    need-info
    on Aug 2, 2023
  11. jingliancui commented on Aug 2, 2023

    @jingliancui
    Author

    then you will found that I use Xamarin.Legacy.Sdk/0.2.0-alpha4 in the csproj. so I'm not sure if this sdk will impact the result.

  12. jpobst commented on Aug 2, 2023

    @jpobst
    Contributor

    It looks like this may be caused by using a very old version of Xamarin.Google.Android.Material. Try updating it to a newer version like 1.9.0.2.

  13. jingliancui commented on Aug 2, 2023

    @jingliancui
    Author

    thanks, will check it later.
    In the mean time I have a question, because I reference the dependency base on the native package's reference here:
    https://github.com/loper7/DateTimePicker
    implementation 'com.google.android.material:material:1.1.0

    if we update the dependency to newer version, is it will possible to occur some issue (for example if we are binding other packages instead of this one.)

  14. jpobst commented on Aug 2, 2023

    @jpobst
    Contributor

    There is always a possibility of something breaking when updating anything. But even if you were using this library in Java, Maven would use a newer version of Material if another library requested it.

    It looks like even that library actually uses a newer version than specified in their readme:
    https://github.com/loper7/DateTimePicker/blob/4a1c55986c52bdc27ffd05bfa236371509b87c5e/date_time_picker/build.gradle#L35

  15. jingliancui commented on Aug 2, 2023

    @jingliancui
    Author

    Ha good catch, and I agree with you. Thank you, let me update nuget and test later.

  16. jingliancui commented on Aug 2, 2023

    @jingliancui
    Author

    But then another question, why xamarin application can pass the build.

  17. moljac commented on Aug 2, 2023

    @moljac
    Contributor

    Ha good catch, and I agree with you. Thank you, let me update nuget and test later.

    Another suggestion: ask (request from) loper7/DateTimePicker author[s] to update their dependencies too.

  18. jpobst commented on Aug 2, 2023

    @jpobst
    Contributor

    But then another question, why xamarin application can pass the build.

    My guess would be that an XF build uses all "older" dependencies that work well together, while MAUI itself uses "newer" dependencies that are causing this conflict with an "older" Material.

    Also, several things about binding projects changed in the transition to .NET 6+, so it could be a change in there that makes things different now.

    https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetEmbeddedResources.md

  19. jingliancui commented on Aug 3, 2023

    @jingliancui
    Author

    thanks all, just tested, It work well after update nuget version of com.google.android.material:material

  20. locked and limited conversation to collaborators on Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: App+Library Buildneed-attention

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions