xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.88k forks source link

[Bug] After updating XF 5.0.0.1931 getting Java.Lang.IllegalArgumentException: Invalid target position at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod #13616

Closed divyesh08 closed 3 years ago

divyesh08 commented 3 years ago

Description

I have updated Xamarin.Forms nuget package version from 4.8.0.1821 to 5.0.0.1931. After updating it I am getting this exception in my app where I have implemented Carousel view. Facing this exception only in Android.

Stack trace:

at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
  at AndroidX.RecyclerView.Widget.RecyclerView+LayoutManager.StartSmoothScroll (AndroidX.RecyclerView.Widget.RecyclerView+SmoothScroller smoothScroller) [0x00027] in D:\a\1\s\generated\androidx.recyclerview.recyclerview\obj\Release\monoandroid90\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:7510 
  at Xamarin.Forms.Platform.Android.ScrollHelper.AnimateScrollToPosition (System.Int32 index, Xamarin.Forms.ScrollToPosition scrollToPosition) [0x00029] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ScrollHelper.cs:62 
  at Xamarin.Forms.Platform.Android.CarouselViewRenderer.ScrollTo (Xamarin.Forms.ScrollToRequestEventArgs args) [0x00037] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:219 
  at Xamarin.Forms.Platform.Android.ItemsViewRenderer`3[TItemsView,TAdapter,TItemsViewSource].ScrollToRequested (System.Object sender, Xamarin.Forms.ScrollToRequestEventArgs args) [0x00022] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:603 
  at Xamarin.Forms.ItemsView.OnScrollToRequested (Xamarin.Forms.ScrollToRequestEventArgs e) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Items\ItemsView.cs:219 
  at Xamarin.Forms.ItemsView.ScrollTo (System.Int32 index, System.Int32 groupIndex, Xamarin.Forms.ScrollToPosition position, System.Boolean animate) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Items\ItemsView.cs:172 
  at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateFromCurrentItem () [0x0003c] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:513 
  at Xamarin.Forms.Platform.Android.CarouselViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00079] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:171 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:383 
  at Xamarin.Forms.Element.SetValueFromRenderer (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:248 
  at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateAdapter () [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:131 
  at Xamarin.Forms.Platform.Android.CarouselViewRenderer.UpdateItemsSource () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:151 
  at Xamarin.Forms.Platform.Android.ItemsViewRenderer`3[TItemsView,TAdapter,TItemsViewSource].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00020] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ItemsViewRenderer.cs:212 
  at Xamarin.Forms.Platform.Android.CarouselViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\CarouselViewRenderer.cs:158 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:266 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:510 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:446 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00226] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:160 
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:56 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:762 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x000cb] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:773 
  at Xamarin.Forms.BindingExpression+WeakPropertyChangedProxy.OnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00012] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:666 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Coeqwety.ViewModels.Base.BaseNotify.SetPropertyChanged (System.String propertyName) [0x0000f] in /Users/differenz159/Documents/Sourcetree/Coeqwety_2/Coeqwety/ViewModels/Base/BaseNotify.cs:31 
  at Coeqwety.ViewModels.Profile.ProfileViewModel.set_CardList (System.Collections.ObjectModel.ObservableCollection`1[T] value) [0x000b5] in /Users/differenz159/Documents/Sourcetree/Coeqwety_2/Coeqwety/ViewModels/Profile/ProfileViewModel.cs:2132 
  at Coeqwety.ViewModels.Wallet.WalletPageViewModel.BindCardAndAccountDetails () [0x00544] in /Users/differenz159/Documents/Sourcetree/Coeqwety_2/Coeqwety/ViewModels/Wallet/WalletPageViewModel.cs:137 
  --- End of managed Java.Lang.IllegalArgumentException stack trace ---
java.lang.IllegalArgumentException: Invalid target position
    at androidx.recyclerview.widget.RecyclerView$SmoothScroller.start(RecyclerView.java:11807)
    at androidx.recyclerview.widget.RecyclerView$LayoutManager.startSmoothScroll(RecyclerView.java:8470)
    at mono.java.lang.RunnableImplementor.n_run(Native Method)
    at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
    {Java.Lang.IllegalArgumentException: Invalid target position
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <42748fc…}

Steps to Reproduce

  1. Update Xamarin.Forms package to latest stable version i.e. 5.0.0.1931
  2. Implement Carousel view in project
  3. Run the project in Android: Make change in property of Carousel view item it will throw this exception

Expected Behavior

It should update property when value get updates and call OnPropertyChanged event without any error.

Actual Behavior

Its not working, throws this error.

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Community 2019 for Mac === Version 8.7.8 (build 4) Installation UUID: 2c1474c0-efa9-4f14-9e08-3d469bbf64ca GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000093 === Mono Framework MDK === Runtime: Mono 6.12.0.93 (2020-02/620cf538206) (64-bit) Package version: 612000093 === Roslyn (Language Service) === 3.7.0-6.20427.1+18ede13943b0bfae1b44ef078b2f3923159bcd32 === NuGet === Version: 5.7.0.6702 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/3.1.402/Sdks SDK Versions: 3.1.402 3.1.302 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 3.1.8 3.1.6 2.1.22 2.1.20 === Xamarin.Profiler === Version: 1.6.15.68 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Apple Developer Tools === Xcode 12.0 (17219) Build 12A7209 === Xamarin.Mac === Version: 6.20.2.2 (Visual Studio Community) Hash: 817b6f72a Branch: d16-7 Build date: 2020-07-18 18:44:59-0400 === Xamarin.iOS === Version: 14.0.0.0 (Visual Studio Community) Hash: 7ec3751a1 Branch: xcode12 Build date: 2020-09-16 11:33:15-0400 === Xamarin Designer === Version: 16.7.0.495 Hash: 03d50a221 Branch: remotes/origin/d16-7-vsmac Build date: 2020-08-28 13:12:52 UTC === Xamarin.Android === Version: 11.0.2.0 (Visual Studio Community) Commit: xamarin-android/d16-7/025fde9 Android SDK: /Users/differenz159/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 7.0 (API level 24) 8.1 (API level 27) SDK Tools Version: 26.1.1 SDK Platform Tools Version: 30.0.4 SDK Build Tools Version: 29.0.2 Build Information: Mono: 83105ba Java.Interop: xamarin/java.interop/d16-7@1f3388a ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f === Microsoft OpenJDK for Mobile === Java SDK: /Users/differenz159/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.7.0.13 Hash: 8380518 Branch: remotes/origin/d16-7~2 Build date: 2020-09-16 05:12:24 UTC === Android Device Manager === Version: 16.7.0.24 Hash: bb090a3 Branch: remotes/origin/d16-7 Build date: 2020-09-16 05:12:46 UTC === Build Information === Release ID: 807080004 Git revision: 9ea7bef96d65cdc3f4288014a799026ccb1993bc Build date: 2020-09-16 17:22:54-04 Build branch: release-8.7 Xamarin extensions: 9ea7bef96d65cdc3f4288014a799026ccb1993bc === Operating System === Mac OS X 10.15.6 Darwin 19.6.0 Darwin Kernel Version 19.6.0 Sun Jul 5 00:43:10 PDT 2020 root:xnu-6153.141.1~9/RELEASE_X86_64 x86_64 ```

Build Logs

Screenshots

Reproduction Link

CarouselDemo.zip

Workaround

Not any

divyesh08 commented 3 years ago

@jsuarezruiz you have closed this bug but when this updates will be available?

jsuarezruiz commented 3 years ago

@divyesh08 The issue have been fixed by https://github.com/xamarin/Xamarin.Forms/pull/13617 Will be available in the next Release.

divyesh08 commented 3 years ago

@divyesh08 The issue have been fixed by #13617 Will be available in the next Release.

New release will come in this month or in next month?