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

Core library: IInstallStateUpdatedListener missing new Android 14 requirements? #813

Open
DM-98 opened this issue Oct 31, 2023 · 4 comments

Comments

@DM-98
Copy link

DM-98 commented Oct 31, 2023

Xamarin.Android Version (eg: 6.0):

14.0

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

Pixel 5 - API 34 (Android 14.0)

Describe your Issue

I have a simple flexible In-App update for my Android app, and then...
After upgrading my simulator, and using the new Pixel 5 - Android 14 (API 34) simulator, I now get exception:

Java.Lang.SecurityException: 'com.companyname.landbrugnet.estate.maui: 
One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts'

Relevant information

Packages used (newest version of Google Play Core):

<PackageReference Include="Xamarin.Google.Android.Play.Core">
	<Version>1.10.3.7</Version>
</PackageReference>

Info: I have tried using the specific App Update nuget package, and I get same exception as this issue:
PatGet/XamarinPlayCoreUpdater#17
Which is:

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

error: name clash: onStateUpdate(Object) in AppUpdateInstallListener and onStateUpdate(StateT) in StateUpdatedListener have the same erasure, yet neither overrides the other public void onStateUpdate (java.lang.Object p0) where StateT is a type-variable: StateT extends Object declared in interface StateUpdatedListener
@HavenDV
Copy link

HavenDV commented Jan 6, 2024

Maybe this package will help you: https://github.com/oscoreio/Maui.Android.InAppUpdates

@pulmuone
Copy link

pulmuone commented Jan 11, 2024

same issue

java.lang.SecurityException: com.gwise.visioninventory: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts


Exception java.lang.SecurityException: com.gwise.visioninventory: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
  at android.os.Parcel.createExceptionOrNull (Parcel.java:3057)
  at android.os.Parcel.createException (Parcel.java:3041)
  at android.os.Parcel.readException (Parcel.java:3024)
  at android.os.Parcel.readException (Parcel.java:2966)
  at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature (IActivityManager.java:5684)
  at android.app.ContextImpl.registerReceiverInternal (ContextImpl.java:1852)
  at android.app.ContextImpl.registerReceiver (ContextImpl.java:1792)
  at android.app.ContextImpl.registerReceiver (ContextImpl.java:1780)
  at android.content.ContextWrapper.registerReceiver (ContextWrapper.java:755)
  at com.google.android.play.core.listener.zzc.zzb (com.google.android.play:core@@1.10.3:3)
  at com.google.android.play.core.listener.zzc.zzf (com.google.android.play:core@@1.10.3:4)
  at com.google.android.play.core.appupdate.zzf.registerListener (com.google.android.play:core@@1.10.3:1)
  at crc643832a0f6fcbae3f9.MainActivity.n_onStart
  at crc643832a0f6fcbae3f9.MainActivity.onStart (MainActivity.java:59)
  at android.app.Instrumentation.callActivityOnStart (Instrumentation.java:1582)
  at android.app.Activity.performStart (Activity.java:8628)
  at android.app.ActivityThread.handleStartActivity (ActivityThread.java:3807)
  at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:225)
  at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:205)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:177)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:98)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2443)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:205)
  at android.os.Looper.loop (Looper.java:294)
  at android.app.ActivityThread.main (ActivityThread.java:8177)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:552)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:971)
Caused by android.os.RemoteException: Remote stack trace:
  at com.android.server.am.ActivityManagerService.registerReceiverWithFeature (ActivityManagerService.java:13908)
  at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2570)
  at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:2720)
  at android.os.Binder.execTransactInternal (Binder.java:1339)
  at android.os.Binder.execTransact (Binder.java:1275)

@pulmuone
Copy link

nuget change : Xamarin.Google.Android.Play.App.Update

You should use the immediate update.

@dellis1972
Copy link
Contributor

The InstallStateUpdateListener has generics so it cannot be bound without causing errors.

You can add the following file to your app with a Build aciton of AndroidJavaSource.

package xamarin.google.android.play.core.install;

import com.google.android.play.core.install.InstallStateUpdatedListener;
import com.google.android.play.core.install.InstallState;

public class InstallStateUpdatedListenerWrapper {
    private InstallStateUpdatedListener installStateUpdatedListener = state -> {
        onStateUpdate (state);
    };

    void onStateUpdate(InstallState state)
    {
        if (stateUpdateListener != null)
            stateUpdateListener.OnStateUpdate(state);
    }

    public InstallStateUpdatedListener GetListener()
    {
        return installStateUpdatedListener;
    }

    public interface InstallStateListener {
        /**
         * Called when an the State is Updated
         *
         * @param state The Install Session State.
         */
        abstract void OnStateUpdate (InstallState state);
    }

    private InstallStateListener stateUpdateListener = null;

    public void setStateUpdateListener (InstallStateListener listener)
    {
        stateUpdateListener = listener;
    }
}

then you can use

installListener = new InstallStateUpdatedListenerWrapper();
installListener.StateUpdate += (sender, args) => {

};

you might also need this target in your csproj to fix a dependecy

  <Target Name="_Foo" AfterTargets="ResolveAndroidTooling" BeforeTargets="_CompileBindingJava">
  <ItemGroup>
    <_ReferenceJavaLibs Include="$(AndroidSdkBuildToolsPath)core-lambda-stubs.jar" />
  </ItemGroup>
  </Target>

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

No branches or pull requests

4 participants