Version Information
- Visual Studio Version 17.3.0 Preview 4.0
- Xamarin.Android SDK version (13.0.0.0):
- AndroidX Libraries as they are in csproj
<PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.3.0.4" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.4.2.1" />
<PackageReference Include="Xamarin.AndroidX.Fragment" Version="1.4.1.2" />
<PackageReference Include="Xamarin.AndroidX.RecyclerView" Version="1.2.1.7" />
<PackageReference Include="Xamarin.AndroidX.SwipeRefreshLayout" Version="1.1.0.9" />
Describe your Issue:
Am trying to start transactions using SupportFragmentManager from AndroidX packages. My Activity is Extending AppCompatActivity also from AndroidX libraries.
Steps to Reproduce
Whenever I try
SupportFragmentManager.BeginTransaction().Replace(Resource.Id.content_frame, fragment, title).AddToBackStack("tag").Commit();
it doesnt go through and start getting these issues form the stack trace
Java.Lang.NoSuchMethodError: no non-static method "Landroidx/fragment/app/FragmentTransaction;.replace(ILandroidx/fragment/app/Fragment;Ljava/lang/String;)Landroidx/fragment/app/FragmentTransaction;"
its the same for Replace, Commit, Add, or any other function I try from the SupportFragmentManager. Have noticed that in the AndroidX package libraries all the functions I try and dont go through have the unsafe keyword. I have also enabled my Visual Studio to run unsafe code to see if the calls would go through but still getting same errors. Any help is appreciated. Thanks!
### Exception Stack trace:
{Java.Lang.NoSuchMethodError: no non-static method "Landroidx/fragment/app/FragmentTransaction;.replace(ILandroidx/fragment/app/Fragment;Ljava/lang/String;)Landroidx/fragment/app/FragmentTransaction;"
at Java.Interop.JniEnvironment.InstanceMethods.GetMethodID(JniObjectReference type, String name, String signature) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:line 11481
at Java.Interop.JniType.GetInstanceMethod(String name, String signature) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:line 236
at Java.Interop.JniPeerMembers.JniInstanceMethods.GetMethodInfo(String encodedMember) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:line 90
at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualObjectMethod(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:line 388
at AndroidX.Fragment.App.FragmentTransaction.Replace(Int32 containerViewId, Fragment fragment, String tag) in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release\net6.0-android\generated\src\AndroidX.Fragment.App.FragmentTransaction.cs:line 694
at FingerCheck.Mobile.Android.EmMainActivity.DisplayView(String title) in D:\code\new-ios-mobile-app\mobile-app\FingerCheck.Mobile.Android\UI\Activities\EmMainActivity.cs:line 153
--- End of managed Java.Lang.NoSuchMethodError stack trace ---
java.lang.NoSuchMethodError: no non-static method "Landroidx/fragment/app/FragmentTransaction;.replace(ILandroidx/fragment/app/Fragment;Ljava/lang/String;)Landroidx/fragment/app/FragmentTransaction;"
at crc646632ed322e08ccbe.EmMainActivity.n_onCreate(Native Method)
at crc646632ed322e08ccbe.EmMainActivity.onCreate(EmMainActivity.java:76)
at android.app.Activity.performCreate(Activity.java:8198)
at android.app.Activity.performCreate(Activity.java:8182)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3765)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3968)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2307)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8512)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
CodePudding user response:
Follow this thread to see resolution Github discussion