英文:
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>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
My android .csproj Packages (i suspect 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>
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论