Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin.AndroidX.Fragment FragmentManager Java.Lang.AbstractMethodError crash #1055

Open
RoNko72 opened this issue Nov 27, 2024 · 2 comments

Comments

@RoNko72
Copy link

RoNko72 commented Nov 27, 2024

Android framework version

net8.0-android

Affected platform version

VS for Mac 17.6.14, .NET 8.0.404

Description

I am getting this crash after adding IOnBackStackChangedListener to my activity:

Java.Lang.AbstractMethodError: abstract method "void androidx.fragment.app.FragmentManager$OnBackStackChangedListener.onBackStackChangeStarted(androidx.fragment.app.Fragment, boolean)"
  at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:20830
  at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:75
  at AndroidX.Fragment.App.FragmentManager.IOnBackStackChangedListener.OnBackStackChangeStarted(Fragment fragment, Boolean pop) in D:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net8.0-android\generated\src\AndroidX.Fragment.App.FragmentManager.cs:986
  at AndroidX.Fragment.App.FragmentManager.IOnBackStackChangedListener.n_OnBackStackChangeStarted_Landroidx_fragment_app_Fragment_Z(IntPtr jnienv, IntPtr native__this, IntPtr native_fragment, Boolean pop) in D:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net8.0-android\generated\src\AndroidX.Fragment.App.FragmentManager.cs:973
  at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLZ_V(_JniMarshal_PPLZ_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, Boolean p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:187
  at java.lang.AbstractMethodError: abstract method "void androidx.fragment.app.FragmentManager$OnBackStackChangedListener.onBackStackChangeStarted(androidx.fragment.app.Fragment, boolean)
  at at onBackStackChangeStarted(Native Method)
  at at onBackStackChangeStarted(MainView.java:211)
  at at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2131)
  at at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2058)
  at at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2001)
  at at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:702)
  at at android.os.Handler.handleCallback(Handler.java:938)
  at at android.os.Handler.dispatchMessage(Handler.java:99)
  at at android.os.Looper.loopOnce(Looper.java:226)
  at at android.os.Looper.loop(Looper.java:313)
  at at android.app.ActivityThread.main(ActivityThread.java:8751)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

Looks like it expects me to override method onBackStackChangeStarted(), but I can't do it.

Steps to Reproduce

  1. On activity add IOnBackStackChanged interface inheritance
  2. Add this activity as listener to SupportFragmentManager - SupportFragmentManager.AddOnBackStackChangedListener(this);
  3. Do actions to invoke onBackStackChangeStarted method.

Did you find any workaround?

No response

Relevant log output

@PhilippC
Copy link

PhilippC commented Dec 1, 2024

I can confirm this issue. It makes it hard or impossible to implement AndroidX based preference screens properly.

@moljac
Copy link
Contributor

moljac commented Dec 2, 2024

@RoNko72 @PhilippC

Thanks for the feedback. I will look into the issue.

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

No branches or pull requests

3 participants