Ошибка при установке Xamarin.Google Play Services.Based в MAUI net 8.0

Open
#1,127 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
android, csharp, firebase

Research direction

Start with the Android-specific PackageReference entries in the shown JKC.csproj and the reported R8 output for androidx/lifecycle/ViewModelKt.class. Reproduce the net8.0-android34.0 build and trace which package references produce obj\Debug\net8.0-android34.0\lp\137 and lp\173; done means the project builds without the duplicate-class error.

Written by the indexing model from the issue text.

Description

needs-info
Android framework version

net8.0-android

Affected platform version

VS 2022 android 34.0

Description

When installing the Plugin.Firebase and Xamarin.Google Play Services.When compiling the project, an error appears to be with the AndroidX transit package, but no matter how much I try to fix it, it still doesn't work and there are only more problems.

console output:

1>MSBUILD : java.exe error JAVA0000: Error in obj\Debug\net8.0-android34.0\lp\137\jl\classes.jar:androidx/lifecycle/ViewModelKt.class:
1>MSBUILD : java.exe error JAVA0000: Type androidx.lifecycle.ViewModelKt is defined multiple times: obj\Debug\net8.0-android34.0\lp\137\jl\classes.jar:androidx/lifecycle/ViewModelKt.class, obj\Debug\net8.0-android34.0\lp\173\jl\classes.jar:androidx/lifecycle/ViewModelKt.class
1>MSBUILD : java.exe error JAVA0000: Compilation failed
1>MSBUILD : java.exe error JAVA0000: java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net8.0-android34.0\lp\137\jl\classes.jar
1>MSBUILD : java.exe error JAVA0000: androidx/lifecycle/ViewModelKt.class
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:135)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.main(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5)
1>MSBUILD : java.exe error JAVA0000: Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net8.0-android34.0\lp\137\jl\classes.jar:androidx/lifecycle/ViewModelKt.class
1>MSBUILD : java.exe error JAVA0000: 	at Version.fakeStackEntry(Version_8.2.33.java:0)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.T.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:5)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:82)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:32)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:31)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:2)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:42)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.b(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:13)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:40)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:122)
1>MSBUILD : java.exe error JAVA0000: 	... 1 more
1>MSBUILD : java.exe error JAVA0000: Caused by: com.android.tools.r8.utils.b: Type androidx.lifecycle.ViewModelKt is defined multiple times: obj\Debug\net8.0-android34.0\lp\137\jl\classes.jar:androidx/lifecycle/ViewModelKt.class, obj\Debug\net8.0-android34.0\lp\173\jl\classes.jar:androidx/lifecycle/ViewModelKt.class
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.Q2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:21)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:54)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:10)
1>MSBUILD : java.exe error JAVA0000: 	at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2056)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.D2.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.graph.m4$a.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:6)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:61)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:12)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.dex.c.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:9)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:45)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.d(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:17)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.D8.c(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:69)
1>MSBUILD : java.exe error JAVA0000: 	at com.android.tools.r8.utils.S0.a(R8_8.2.33_429c93fd24a535127db6f4e2628eb18f2f978e02f99f55740728d6b22bef16dd:28)
1>MSBUILD : java.exe error JAVA0000: 	... 6 more
1>MSBUILD : java.exe error JAVA0000: Directory 'obj\Debug\net8.0-android34.0\lp\137' is from 'androidx.lifecycle.lifecycle-viewmodel-android.aar'.
1>Сборка проекта "JKC.csproj" завершена с ошибкой.

код .csproj :

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net8.0-maccatalyst;net8.0-android34.0</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
    
    <OutputType>Exe</OutputType>
    <RootNamespace>JKC</RootNamespace>
    <UseMaui>true</UseMaui>
    <SingleProject>true</SingleProject>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>

    <!-- Display name -->
    <ApplicationTitle>JKC</ApplicationTitle>
    <ApplicationId>com.companyname.jkc</ApplicationId>
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
    <ApplicationVersion>1</ApplicationVersion>

    <!-- Platform versions -->
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">31.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
    <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    
    <!-- Temporary build settings to fix conflicts -->
    <AndroidLinkMode>None</AndroidLinkMode>
    <AndroidEnableProguard>false</AndroidEnableProguard>
    <AssemblyVersion>1.0.0</AssemblyVersion>
  </PropertyGroup>

  <!-- Conditional properties for different configurations -->
  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
    <ApplicationTitle>ЖИЛКОМЦЕНТР</ApplicationTitle>
    <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-maccatalyst|AnyCPU'">
    <ApplicationTitle>ЖИЛКОМЦЕНТР</ApplicationTitle>
    <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-windows10.0.19041.0|AnyCPU'">
    <ApplicationTitle>ЖИЛКОМЦЕНТР</ApplicationTitle>
    <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
    <ApplicationTitle>ЖИЛКОМЦЕНТР</ApplicationTitle>
    <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-maccatalyst|AnyCPU'">
    <ApplicationTitle>ЖИЛКОМЦЕНТР</ApplicationTitle>
    <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-windows10.0.19041.0|AnyCPU'">
    <ApplicationTitle>ЖИЛКОМЦЕНТР</ApplicationTitle>
    <ApplicationDisplayVersion>1.0.0</ApplicationDisplayVersion>
  </PropertyGroup>

  <!-- Resources -->
  <ItemGroup>
    <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
    <MauiIcon Include="Resources\AppIcon\logo_desc.svg" />
    <MauiSplashScreen Include="Resources\Images\logo_splash.svg" Color="#FFFFFF" BaseSize="128,128" />
    <MauiSplashScreen Include="Resources\Images\money_menu.png" />
    <MauiImage Include="Resources\Images\*" />
    <MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
    <MauiFont Include="Resources\Fonts\*" />
    <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
  </ItemGroup>

  <ItemGroup>
    <MauiImage Remove="Resources\Images\logo_splash.svg" />
    <MauiImage Remove="Resources\Images\money_menu.png" />
    <None Remove="Resources\AppIcon\logo_desc.svg" />
  </ItemGroup>

  <!-- Common packages -->
  <ItemGroup>
    <PackageReference Include="CommunityToolkit.Maui" Version="8.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
    <PackageReference Include="Plugin.Fingerprint" Version="3.0.0-beta.1" />
    <PackageReference Include="SkiaSharp" Version="3.116.1" />
    <PackageReference Include="Xamarin.MediaGallery" Version="2.2.1" />
  </ItemGroup>

  <!-- Android-specific packages -->
  <ItemGroup Condition="'$(TargetFramework)' == 'net8.0-android34.0'">
    <!-- Firebase -->
    <PackageReference Include="Plugin.Firebase.CloudMessaging" Version="3.1.2" />
    <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.5.0.4" />
    <GoogleServicesJson Include="Platforms\Android\google-services.json" />
    
    <!-- AndroidX packages with consistent versions -->
    <PackageReference Include="Xamarin.AndroidX.Core" Version="1.15.0.2" />
    <PackageReference Include="Xamarin.AndroidX.Collection" Version="1.4.5.2" />
    <PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.5.2" />
  
	<!-- AndroidX Lifecycle - единые версии -->
	  <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.7.2.1" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.6.2" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime" Version="2.8.7.2" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.8.7.2" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel.Ktx" Version="2.6.2" />
  </ItemGroup>

  <!-- XAML compilation -->
  <ItemGroup>
    <MauiXaml Update="Pages\CodePage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\DefaultPage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\DocsPage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\Kvitanciya.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\LoginPage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\MoneyPage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\PayPageSber.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\PokazaniyaPage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
    <MauiXaml Update="Pages\SettingsPage.xaml">
      <Generator>MSBuild:Compile</Generator>
    </MauiXaml>
  </ItemGroup>

</Project>
Steps to Reproduce

1.install Plugin.Firebase
2.install Xamarin.GooglePlayServices.Base
3.launch the project build

Did you find any workaround?

No response

Relevant log output

Dominant language
C#
Stars
318
Forks
73
Avg merge
2d 6h
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/android-libraries

All issues in dotnet/android-libraries

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.