Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

DotNet-8.0-Android : In-App Update Build Failing #900

Closed
2 tasks
dev-abcdevelopers opened this issue Aug 12, 2024 · 0 comments · Fixed by #904
Closed
2 tasks

DotNet-8.0-Android : In-App Update Build Failing #900

dev-abcdevelopers opened this issue Aug 12, 2024 · 0 comments · Fixed by #904

Comments

@dev-abcdevelopers
Copy link

dev-abcdevelopers commented Aug 12, 2024

DotNet-8.0-Android

Operating System & Version (eg: Mac OSX 10.11): Win11

Google Play Services Version

  • GPS-FB with AndroidX dependencies (versions 118.5.0.1)

  • GPS-FB with Android.Support (legacy) dependencies : AnxdroidX with Material UI

Describe your Issue

Using this Nuget package Xamarin.Google.Android.Play.Core.AppUpdate (Version: 2.1.0.9)
Build Is Failing with this Code :

error: Home_AppUpdateInstallUpdateListner is not abstract and does not override abstract method onStateUpdate(InstallState) in StateUpdatedListener
public class Home_AppUpdateInstallUpdateListner
error: name clash: onStateUpdate(Object) in Home_AppUpdateInstallUpdateListner and onStateUpdate(InstallState) in StateUpdatedListener have the same erasure, yet neither overrides the other
public void onStateUpdate (java.lang.Object p0)

Relevant information

Packages used:

<ItemGroup>
   <PackageReference Include="Com.Airbnb.Android.Lottie" Version="4.2.2" />
   <PackageReference Include="Microsoft.Maui.Essentials" Version="8.0.80" />
   <PackageReference Include="OneSignalSDK.DotNet" Version="5.2.0" />
   <PackageReference Include="Xamarin.AndroidX.Activity" Version="1.9.1" />
   <PackageReference Include="Xamarin.AndroidX.Activity.Ktx" Version="1.9.1" />
   <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0.1" />
   <PackageReference Include="Xamarin.AndroidX.CardView" Version="1.0.0.29" />
   <PackageReference Include="Xamarin.AndroidX.Collection.Jvm" Version="1.4.2" />
   <PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.4.2" />
   <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.4" />
   <PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.8.4" />
   <PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime" Version="2.8.4" />
   <PackageReference Include="Xamarin.Firebase.Messaging" Version="124.0.0.1" />
   <PackageReference Include="Xamarin.Google.Android.Material" Version="1.11.0.1" />
   <PackageReference Include="Xamarin.Google.Android.Play.App.Update" Version="2.1.0.9" />
   <PackageReference Include="Xamarin.Google.Android.Play.App.Update.Ktx" Version="2.1.0.9" />
   <PackageReference Include="Xamarin.Google.Dagger" Version="2.51.1.1" />
   <PackageReference Include="Xamarin.GooglePlayServices.Base" Version="118.5.0.1" />
   <PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="2.0.0.1" />
</ItemGroup>

Build settings (tools)

<PropertyGroup>
  <TargetFramework>net8.0-android</TargetFramework>
   <SupportedOSPlatformVersion>26.0</SupportedOSPlatformVersion>
   <OutputType>Exe</OutputType>
   <Nullable>enable</Nullable>
   <ImplicitUsings>enable</ImplicitUsings>
   <ApplicationId>com.abcdev.policytracker</ApplicationId>
   <ApplicationVersion>1</ApplicationVersion>
   <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
   <AndroidSigningKeyStore>abcdev.keystore</AndroidSigningKeyStore>
   <AndroidEnableViewBinding>true</AndroidEnableViewBinding>
</PropertyGroup>

Minimal Repro Code Sample

 using Xamarin.Google.Android.Play.Core.AppUpdate;
 using Xamarin.Google.Android.Play.Core.AppUpdate.Install;
 using Xamarin.Google.Android.Play.Core.AppUpdate.Install.Model;

 public IAppUpdateManager? AppUpdateManager;
 private AppUpdateInstallUpdateListner? MyInstallUpdateListner;
 public const int AppUpdateTypeSupported = AppUpdateType.Flexible;
 
protected override void OnCreate(Bundle? savedInstanceState)
{
     base.OnCreate(savedInstanceState);
     HomeLayout = BindingHome.Inflate(LayoutInflater);
     SetContentView(HomeLayout.Root);
     try
     {
         OneSignal.Notifications.RequestPermissionAsync(true);
         App.SetUserId();
         AppUpdateManager = AppUpdateManagerFactory.Create(this);
         MyInstallUpdateListner = new AppUpdateInstallUpdateListner(AppUpdateManager);
         AppUpdateManager.RegisterListener(MyInstallUpdateListner);
         var AppUpdateInfoTask = AppUpdateManager.GetAppUpdateInfo();
         AppUpdateInfoTask.AddOnSuccessListener(new InAppUpdateSuccessListener(AppUpdateManager, this));
     }
     catch (Exception Ex) { App.ReportError(Ex); }
 }
  
  public class InAppUpdateSuccessListener(IAppUpdateManager? AppUpdateManager, Activity? Home) : Java.Lang.Object, IOnSuccessListener
{
    private readonly IAppUpdateManager? AppUpdateManager = AppUpdateManager;
    private readonly Activity? Home = Home;

    public void OnSuccess(Java.Lang.Object result)
    {
        if (result is not AppUpdateInfo EInfo)
        {
            return;
        }

        if (EInfo.InstallStatus() == InstallStatus.Downloaded)
        {
            AppUpdateManager?.CompleteUpdate();
            return;
        }

        int IAvailability = EInfo.UpdateAvailability();
        if ((IAvailability.Equals(UpdateAvailability.UpdateAvailable) ||
            IAvailability.Equals(UpdateAvailability.DeveloperTriggeredUpdateInProgress)) &&
            EInfo.IsUpdateTypeAllowed(AppUpdateType.Immediate))
        {
            AppUpdateOptions? Options = AppUpdateOptions.NewBuilder(AppUpdateTypeSupported).Build();
            AppUpdateManager?.StartUpdateFlow(EInfo, Home, Options);
        }
    }
}

public class AppUpdateInstallUpdateListner(IAppUpdateManager? AppUpdateManager) : Java.Lang.Object, IInstallStateUpdatedListener
{
    public IAppUpdateManager? AppUpdateManager = AppUpdateManager;

    public void OnStateUpdate(Java.Lang.Object p0)
    {

        if (p0 is not InstallState state)
        {
            return;
        }

        if (state.InstallStatus() == InstallStatus.Downloaded)
        {
            AppUpdateManager?.CompleteUpdate();
        }
    }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant