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

Xamarin.Google.Android.Play.Core can't implement IInstallStateUpdatedListener #673

Closed
rgajadin opened this issue Aug 8, 2022 · 15 comments · Fixed by #709
Closed

Xamarin.Google.Android.Play.Core can't implement IInstallStateUpdatedListener #673

rgajadin opened this issue Aug 8, 2022 · 15 comments · Fixed by #709

Comments

@rgajadin
Copy link

rgajadin commented Aug 8, 2022

Google Play Services Version

Xamarin.Google.Android.Play.Core 1.10.3.1

Describe your Issue

Error JAVAC0000 javac.exe:  error: MainActivity is not abstract and does not override abstract method onStateUpdate(InstallState) in StateUpdatedListener

Error JAVAC0000 javac.exe:  error: name clash: onStateUpdate(Object) in MainActivity and onStateUpdate(InstallState) in StateUpdatedListener have the same erasure, yet neither overrides the other

Relevant information

Packages used:

    <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.4.2.1" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="1.6.1.1" />
    <PackageReference Include="Xamarin.Essentials" Version="1.7.3" />
    <PackageReference Include="Xamarin.Google.Android.Play.Core" Version="1.10.3.1"/>

Minimal Repro Code Sample

Created a new project so only thing in there

 public class MainActivity : AppCompatActivity, IInstallStateUpdatedListener
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
        }

        public void OnStateUpdate(Object p0)
        {
        }
    }

Adding abstract makes no difference it just gives these errors then

Error JAVAC0000 javac.exe:  error: StateUpdatedListener cannot be inherited with different arguments: <com.google.android.play.core.install.InstallState> and <>

Error JAVAC0000 javac.exe:  error: name clash: onStateUpdate(Object) in MainActivity and onStateUpdate(InstallState) in StateUpdatedListener have the same erasure, yet neither overrides the other
public void onStateUpdate (java.lang.Object p0)
@kkppstudios
Copy link

Looks like the same problem in this other repo. Should be a good clue.

@Cheesebaron
Copy link

Can we please have a fix for this?

@moljac
Copy link
Member

moljac commented Nov 11, 2022

Automagically closed by

#709

Please open new issue if problem persists!

And report if fix works too.

@Cheesebaron
Copy link

Cheesebaron commented Jan 19, 2023

This one seems to still be an issue. App fails building if I try implementing IInstallStateUpdatedListener:

public class AppUpdateInstallStateListener: Object, IInstallStateUpdatedListener
{
    private readonly Action<InstallState> _onStateUpdate;

    public AppUpdateInstallStateListener(Action<InstallState> onStateUpdate)
    {
        _onStateUpdate = onStateUpdate;
    }

    public void OnStateUpdate(Object p0)
    {
        if (p0 is InstallState installState)
            _onStateUpdate.Invoke(installState);
    }
}

Build error:

         obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(4,8): javac error JAVAC0000:  error: AppUpdateInstallStateListener is not abstract and does not override abstract method onStateUpdate(InstallState) in StateUpdatedListener
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(4,8): javac error JAVAC0000: public class AppUpdateInstallStateListener
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(4,8): javac error JAVAC0000: 
         obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(30,14): javac error JAVAC0000:  error: name clash: onStateUpdate(Object) in AppUpdateInstallStateListener and onStateUpdate(InstallState) in StateUpdatedListener have the same erasure, yet neither overrides the other
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(30,14): javac error JAVAC0000: 	public void onStateUpdate (java.lang.Object p0)
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(30,14): javac error JAVAC0000: 

The generated code looks like:

package crc64ff75450e0e434054;


public class AppUpdateInstallStateListener
	extends java.lang.Object
	implements
		mono.android.IGCUserPeer,
		com.google.android.play.core.install.InstallStateUpdatedListener,
		com.google.android.play.core.listener.StateUpdatedListener
{
/** @hide */
	public static final String __md_methods;
	static {
		__md_methods = 
			"n_onStateUpdate:(Ljava/lang/Object;)V:GetOnStateUpdate_Ljava_lang_Object_Handler:Xamarin.Google.Android.Play.Core.Listener.IStateUpdatedListenerInvoker, Xamarin.Google.Android.Play.Core.Common\n" +
			"";
		mono.android.Runtime.register ("TrackMan.DrivingRangeApp.Droid.Listeners.AppUpdateInstallStateListener, TrackMan.DrivingRangeApp.Droid", AppUpdateInstallStateListener.class, __md_methods);
	}


	public AppUpdateInstallStateListener ()
	{
		super ();
		if (getClass () == AppUpdateInstallStateListener.class) {
			mono.android.TypeManager.Activate ("TrackMan.DrivingRangeApp.Droid.Listeners.AppUpdateInstallStateListener, TrackMan.DrivingRangeApp.Droid", "", this, new java.lang.Object[] {  });
		}
	}


	public void onStateUpdate (java.lang.Object p0)
	{
		n_onStateUpdate (p0);
	}

	private native void n_onStateUpdate (java.lang.Object p0);

	private java.util.ArrayList refList;
	public void monodroidAddReference (java.lang.Object obj)
	{
		if (refList == null)
			refList = new java.util.ArrayList ();
		refList.add (obj);
	}

	public void monodroidClearReferences ()
	{
		if (refList != null)
			refList.clear ();
	}
}

This is with the following packages:

    <PackageVersion Include="Xamarin.Google.Android.Play.App.Update" Version="2.0.1" />
    <PackageVersion Include="Xamarin.Google.Android.Play.Review" Version="2.0.1" />
    <PackageVersion Include="Xamarin.GooglePlayServices.Base" Version="118.1.0" />
    <PackageVersion Include="Xamarin.GooglePlayServices.Location" Version="120.0.0" />
    <PackageVersion Include="Xamarin.GooglePlayServices.Maps" Version="118.1.0" />

If I then add:

    <PackageVersion Include="Xamarin.Google.Android.Play.Core" Version="1.10.3.3" />

Then I now get:

/Users/tomaszcielecki/git/DrivingRangeApp/TrackMan.DrivingRangeApp.Droid/Listeners/AppUpdateSuccessListener.cs(11,29): error CS0433: The type 'AppUpdateInfo' exists in both 'Xamarin.Google.Android.Play.App.Update, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Xamarin.Google.Android.Play.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

@Cheesebaron
Copy link

Seems like everything from Play.App.Update and Play.Review was added into Play.Core?

@moljac
Copy link
Member

moljac commented Jan 19, 2023

please open new issue

@moljac
Copy link
Member

moljac commented Jan 19, 2023

Seems like everything from Play.App.Update and Play.Review was added into Play.Core?

I am not API expert and yes google does shuffle stuff around and I am mostly unaware until someone hits issue.

@Cheesebaron
Copy link

I ended up removing the Play.App.Update and Play.Review packages and now only use Play.Core then it seems to work fine. At least it builds now.

@pulmuone
Copy link

pulmuone commented Jun 7, 2023

same issue

@Cheesebaron
Copy link

@pulmuone same issue what?

@pulmuone
Copy link

pulmuone commented Jun 7, 2023

@pulmuone same issue what?
public class AppUpdateInstallStateListener : Java.Lang.Object, Com.Google.Android.Play.Core.Install.IInstallStateUpdatedListener
{
public void OnStateUpdate(Object p0)
{
var p1 = p0.JavaCast();

	if (p1.InstallStatus() == InstallStatus.Downloaded)
	{
		appUpdateManager.CompleteUpdate();
	}
}

}

Error warning: unknown enum constant Scope.LIBRARY_GROUP_PREFIX reason: class file for androidx.annotation.RestrictTo$Scope not found

error: MainActivity_AppUpdateInstallStateListener is not abstract and does not override abstract method onStateUpdate(InstallState) in StateUpdatedListener

Error error: name clash: onStateUpdate(Object) in MainActivity_AppUpdateInstallStateListener and onStateUpdate(InstallState) in StateUpdatedListener have the same erasure, yet neither overrides the other
public void onStateUpdate (java.lang.Object p0) BarcodeScanner.Android D:\01.SourcePrivate\BarcodeScanner2\BarcodeScanner\BarcodeScanner.Android\obj\Debug\130\android\src\crc64531d25dd220eec0f\MainActivity_AppUpdateInstallStateListener.java 30

image

@Cheesebaron
Copy link

And which packages are you using? See my comment here: #673 (comment)

@pulmuone
Copy link

pulmuone commented Jun 7, 2023

And which packages are you using? See my comment here: #673 (comment)

don't use Play.App.Update and Play.Review

Conflict with Plugin.StoreReview.

@Cheesebaron
Copy link

Do you really need a plugin for that? It is 2-3 lines per platform to trigger store reivews.

@kudchikarsk
Copy link

This one seems to still be an issue. App fails building if I try implementing IInstallStateUpdatedListener:

public class AppUpdateInstallStateListener: Object, IInstallStateUpdatedListener
{
    private readonly Action<InstallState> _onStateUpdate;

    public AppUpdateInstallStateListener(Action<InstallState> onStateUpdate)
    {
        _onStateUpdate = onStateUpdate;
    }

    public void OnStateUpdate(Object p0)
    {
        if (p0 is InstallState installState)
            _onStateUpdate.Invoke(installState);
    }
}

Build error:

         obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(4,8): javac error JAVAC0000:  error: AppUpdateInstallStateListener is not abstract and does not override abstract method onStateUpdate(InstallState) in StateUpdatedListener
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(4,8): javac error JAVAC0000: public class AppUpdateInstallStateListener
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(4,8): javac error JAVAC0000: 
         obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(30,14): javac error JAVAC0000:  error: name clash: onStateUpdate(Object) in AppUpdateInstallStateListener and onStateUpdate(InstallState) in StateUpdatedListener have the same erasure, yet neither overrides the other
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(30,14): javac error JAVAC0000: 	public void onStateUpdate (java.lang.Object p0)
       obj/Debug/net7.0-android/android/src/crc64ff75450e0e434054/AppUpdateInstallStateListener.java(30,14): javac error JAVAC0000: 

The generated code looks like:

package crc64ff75450e0e434054;


public class AppUpdateInstallStateListener
	extends java.lang.Object
	implements
		mono.android.IGCUserPeer,
		com.google.android.play.core.install.InstallStateUpdatedListener,
		com.google.android.play.core.listener.StateUpdatedListener
{
/** @hide */
	public static final String __md_methods;
	static {
		__md_methods = 
			"n_onStateUpdate:(Ljava/lang/Object;)V:GetOnStateUpdate_Ljava_lang_Object_Handler:Xamarin.Google.Android.Play.Core.Listener.IStateUpdatedListenerInvoker, Xamarin.Google.Android.Play.Core.Common\n" +
			"";
		mono.android.Runtime.register ("TrackMan.DrivingRangeApp.Droid.Listeners.AppUpdateInstallStateListener, TrackMan.DrivingRangeApp.Droid", AppUpdateInstallStateListener.class, __md_methods);
	}


	public AppUpdateInstallStateListener ()
	{
		super ();
		if (getClass () == AppUpdateInstallStateListener.class) {
			mono.android.TypeManager.Activate ("TrackMan.DrivingRangeApp.Droid.Listeners.AppUpdateInstallStateListener, TrackMan.DrivingRangeApp.Droid", "", this, new java.lang.Object[] {  });
		}
	}


	public void onStateUpdate (java.lang.Object p0)
	{
		n_onStateUpdate (p0);
	}

	private native void n_onStateUpdate (java.lang.Object p0);

	private java.util.ArrayList refList;
	public void monodroidAddReference (java.lang.Object obj)
	{
		if (refList == null)
			refList = new java.util.ArrayList ();
		refList.add (obj);
	}

	public void monodroidClearReferences ()
	{
		if (refList != null)
			refList.clear ();
	}
}

This is with the following packages:

    <PackageVersion Include="Xamarin.Google.Android.Play.App.Update" Version="2.0.1" />
    <PackageVersion Include="Xamarin.Google.Android.Play.Review" Version="2.0.1" />
    <PackageVersion Include="Xamarin.GooglePlayServices.Base" Version="118.1.0" />
    <PackageVersion Include="Xamarin.GooglePlayServices.Location" Version="120.0.0" />
    <PackageVersion Include="Xamarin.GooglePlayServices.Maps" Version="118.1.0" />

If I then add:

    <PackageVersion Include="Xamarin.Google.Android.Play.Core" Version="1.10.3.3" />

Then I now get:

/Users/tomaszcielecki/git/DrivingRangeApp/TrackMan.DrivingRangeApp.Droid/Listeners/AppUpdateSuccessListener.cs(11,29): error CS0433: The type 'AppUpdateInfo' exists in both 'Xamarin.Google.Android.Play.App.Update, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Xamarin.Google.Android.Play.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

How did you retrieved generated java code?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants