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

huangapple go评论84阅读模式
英文:

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

问题

以下是您的内容的翻译:

在过去的几天里,我一直在努力将我的应用从Xamarin.Forms迁移到MAUI。我已经解决了数十个错误,但这个错误让我无法理解。

错误:

MSBUILD:java.exe错误JAVA0000:.nuget\packages\xamarin.kotlin.stdlib.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错误JAVA0000:类型kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion定义多次:.nuget\packages\xamarin.kotlin.stdlib.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.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错误JAVA0000:编译失败
java.exe错误JAVA0000:java.lang.RuntimeException:com.android.tools.r8.CompilationFailedException:编译无法完成,来源:.nuget\packages\xamarin.kotlin.stdlib.8.10\buildTransitive\net6.0-android31.0....\jar\org.jetbrains.kotlin.kotlin-stdlib-1.8.10.jar
2>MSBUILD:java.exe错误JAVA0000:kotlin/internal/jdk7/JDK7PlatformImplementations$ReflectSdkVersion.class

随后是数百个警告,如下所示:

2>JAVAC:警告:未知的枚举常量Scope.LIBRARY_GROUP_PREFIX
2>JAVAC:警告:未知的枚举常量Scope.LIBRARY
2>JAVAC:警告:未知的枚举常量Scope.LIBRARY
2>JAVAC:警告:未知的枚举常量Scope.LIBRARY_GROUP_PREFIX

我的android .csproj Packages(我怀疑是nugets)

<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>
<!-- <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>
英文:

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.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.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.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.8.10\buildTransitive\net6.0-android31.0....\jar\org.jetbrains.kotlin.kotlin-stdlib-1.8.10.jar
2&gt;MSBUILD : java.exe error JAVA0000: kotlin/internal/jdk7/JDK7PlatformImplementations$ReflectSdkVersion.class

Followed by hundreds of warnings such as:

2&gt;JAVAC : warning : unknown enum constant Scope.LIBRARY_GROUP_PREFIX
2&gt;JAVAC : warning : unknown enum constant Scope.LIBRARY
2&gt;JAVAC : warning : unknown enum constant Scope.LIBRARY
2&gt;JAVAC : warning : unknown enum constant Scope.LIBRARY_GROUP_PREFIX

My android .csproj Packages (i suspect nugets)

 &lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
 &lt;PropertyGroup&gt;
 &lt;OutputType&gt;Exe&lt;/OutputType&gt;
 &lt;PublishTrimmed&gt;true&lt;/PublishTrimmed&gt;
 &lt;TrimMode&gt;link&lt;/TrimMode&gt;
 &lt;ImplicitUsings&gt;enable&lt;/ImplicitUsings&gt;
 &lt;UseMaui&gt;true&lt;/UseMaui&gt;

&lt;SupportedOSPlatformVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;android&#39;&quot;&gt;29.0&lt;/SupportedOSPlatformVersion&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot; &#39;$(Configuration)|$(Platform)&#39; == &#39;Debug|AnyCPU&#39; &quot;&gt;
     &lt;EnableLLVM&gt;true&lt;/EnableLLVM&gt;
     &lt;AndroidEnableProfiledAot&gt;false&lt;/AndroidEnableProfiledAot&gt;
     &lt;EmbedAssembliesIntoApk&gt;true&lt;/EmbedAssembliesIntoApk&gt;
     &lt;!--&lt;AndroidDexTool&gt;d8&lt;/AndroidDexTool&gt;
     &lt;AndroidLinkTool&gt;r8&lt;/AndroidLinkTool&gt;--&gt;
     &lt;AndroidPackageFormat&gt;aab&lt;/AndroidPackageFormat&gt;
     &lt;AndroidCreatePackagePerAbi&gt;false&lt;/AndroidCreatePackagePerAbi&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup&gt;
     &lt;TargetFrameworks&gt;net7.0-android&lt;/TargetFrameworks&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(TargetFramework)|$(Platform)&#39;==&#39;Debug|net7.0-android|AnyCPU&#39;&quot;&gt;
     &lt;Optimize&gt;True&lt;/Optimize&gt;
   &lt;/PropertyGroup&gt;
   &lt;PropertyGroup Condition=&quot;&#39;$(Configuration)|$(TargetFramework)|$(Platform)&#39;==&#39;Release|net7.0-android|AnyCPU&#39;&quot; /&gt;
   &lt;ItemGroup&gt;
     &lt;PackageReference Include=&quot;CommunityToolkit.Maui.Markup&quot; Version=&quot;3.1.0&quot; /&gt;
     &lt;PackageReference Include=&quot;FirebaseAuthentication.net&quot;&gt;
       &lt;Version&gt;4.0.2&lt;/Version&gt;
     &lt;/PackageReference&gt;
     &lt;PackageReference Include=&quot;Refractored.MvvmHelpers&quot; Version=&quot;1.6.2&quot; /&gt;
     &lt;PackageReference Include=&quot;sqlite-net-pcl&quot;&gt;
       &lt;Version&gt;1.8.116&lt;/Version&gt;
     &lt;/PackageReference&gt;
     &lt;PackageReference Include=&quot;Xamarin.AndroidX.Annotation&quot; Version=&quot;1.6.0.1&quot; /&gt;
     &lt;PackageReference Include=&quot;Xamarin.AndroidX.RecyclerView&quot;&gt;
       &lt;Version&gt;1.3.0&lt;/Version&gt;
     &lt;/PackageReference&gt;
     &lt;PackageReference Include=&quot;Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers&quot; Version=&quot;0.4.421302&quot;&gt;
      &lt;PrivateAssets&gt;all&lt;/PrivateAssets&gt;
     &lt;/PackageReference&gt;
     &lt;PackageReference Include=&quot;Xamarin.AndroidX.Work.Runtime&quot; Version=&quot;2.7.1.5&quot; /&gt;
     &lt;PackageReference Include=&quot;Xamarin.GooglePlayServices.Base&quot; Version=&quot;118.1.0&quot; /&gt;
&lt;/ItemGroup&gt;
&lt;ItemGroup&gt;
&lt;GoogleServicesJson Include=&quot;google-services.json&quot; /&gt;
&lt;!--&lt;ProguardConfiguration Include=&quot;proguard.cfg&quot; /&gt;--&gt;
&lt;/ItemGroup&gt;
&lt;/Project&gt;

答案1

得分: 0

  • 将整个解决方案从 net7.0 降级为 net6.0
  • 隐式包含 xamarin.kotlin.stdlib JDK7(以及 JDK8 以防万一)的版本为 1.8.0。
英文:

Solution that worked for me:

  • Downgrading entire solution from net7.0 to net6.0
  • Implicitly including xamarin.kotlin.stdlib JDK7 (and JDK8 just in case) for version 1.8.0.

huangapple
  • 本文由 发表于 2023年5月6日 20:00:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76188745.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定