Skip to content

Error in xamarin.kotlin.stdlib ($ReflectSdkVersion is defined multiple times) after migration from Xamarin.Forms #14954

@ppiekarski2

Description

@ppiekarski2

Description

Hey,

For last few days i;m fighting with migrating my app from Xamarin.Forms to MAUI.
I solved dozens of errors already but this one - i cannot wrap my head around.

Error:

MSBUILD : java.exe error JAVA0000: Error in \.nuget\packages\xamarin.kotlin.stdlib\1.8.10\buildTransitive\net6.0-android31.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-1.8.10.jar:kotlin/internal/jdk7/JDK7PlatformImplementations$ReflectSdkVersion.class:
MSBUILD : java.exe error JAVA0000: Type kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion is defined multiple times: \.nuget\packages\xamarin.kotlin.stdlib\1.8.10\buildTransitive\net6.0-android31.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-1.8.10.jar:kotlin/internal/jdk7/JDK7PlatformImplementations$ReflectSdkVersion.class, \.nuget\packages\xamarin.kotlin.stdlib.jdk7\1.7.20.1\buildTransitive\net6.0-android31.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-jdk7-1.7.20.jar:kotlin/internal/jdk7/JDK7PlatformImplementations$ReflectSdkVersion.class
java.exe error JAVA0000: Compilation failed
 java.exe error JAVA0000: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: \.nuget\packages\xamarin.kotlin.stdlib\1.8.10\buildTransitive\net6.0-android31.0\..\..\jar\org.jetbrains.kotlin.kotlin-stdlib-1.8.10.jar
2>MSBUILD : java.exe error JAVA0000: kotlin/internal/jdk7/JDK7PlatformImplementations$ReflectSdkVersion.class
Followed by hundreds of warnings such as:
2>JAVAC : warning : unknown enum constant Scope.LIBRARY_GROUP_PREFIX
2>JAVAC : warning : unknown enum constant Scope.LIBRARY
2>JAVAC : warning : unknown enum constant Scope.LIBRARY
2>JAVAC : warning : unknown enum constant Scope.LIBRARY_GROUP_PREFIX

Steps to Reproduce

I still can't start my app that worked on Xamarin.Forms so... hard to give exact steps, i'm in the middle of migration.
These are my csproj settings for Android:

 <Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <OutputType>Exe</OutputType>
 <PublishTrimmed>true</PublishTrimmed>
 <TrimMode>link</TrimMode>
 <ImplicitUsings>enable</ImplicitUsings>
 <UseMaui>true</UseMaui>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">29.0</SupportedOSPlatformVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <EnableLLVM>true</EnableLLVM>
     <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
     <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
     <!-- Didn't affect the outcome
     <AndroidDexTool>d8</AndroidDexTool>
     <AndroidLinkTool>r8</AndroidLinkTool>-->
     <AndroidPackageFormat>aab</AndroidPackageFormat>
     <AndroidCreatePackagePerAbi>false</AndroidCreatePackagePerAbi>
   </PropertyGroup>
   <PropertyGroup>
     <TargetFrameworks>net7.0-android</TargetFrameworks>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-android|AnyCPU'">
     <Optimize>True</Optimize>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-android|AnyCPU'" />
   <ItemGroup>
     <PackageReference Include="CommunityToolkit.Maui.Markup" Version="3.1.0" />
     <PackageReference Include="FirebaseAuthentication.net">
       <Version>4.0.2</Version>
     </PackageReference>
     <PackageReference Include="Refractored.MvvmHelpers" Version="1.6.2" />
     <PackageReference Include="sqlite-net-pcl">
       <Version>1.8.116</Version>
     </PackageReference>
     <PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.6.0.1" />
     <PackageReference Include="Xamarin.AndroidX.RecyclerView">
       <Version>1.3.0</Version>
     </PackageReference>
     <PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302">
      <PrivateAssets>all</PrivateAssets>
     </PackageReference>
     <PackageReference Include="Xamarin.AndroidX.Work.Runtime" Version="2.7.1.5" />
     <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.1.0" />
</ItemGroup>
<ItemGroup>
<GoogleServicesJson Include="google-services.json" />
<!--<ProguardConfiguration Include="proguard.cfg" />-->
</ItemGroup>
</Project>

Link to public reproduction project repository

N/A

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android

Did you find any workaround?

nope

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions