alexrainman / CarouselView

CarouselView control for Xamarin Forms
MIT License
436 stars 176 forks source link

[Android] Blocking: When changing main page get error #518

Closed PWaliaDev closed 5 years ago

PWaliaDev commented 5 years ago

When changing Main page of application from Carousel View to something else get below error

Unable to activate instance of type Com.ViewPagerIndicator.CirclePageIndicator from native handle 0xff91625c (key_handle 0x379aca3). ---> System.MissingMethodException: No constructor found for Com.ViewPagerIndicator.CirclePageIndicator::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown. at Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.

Also I tried ways mentioned in this ticket #489 but nothing works

if I add Xamarin.Android.Support.ViewPager then get below error.

Error XA2002: Can not resolve reference: Xamarin.Android.Support.ViewPager, referenced by Com.ViewPagerIndicator. Please add a NuGet package or assembly reference for Xamarin.Android.Support.ViewPager, or remove the reference to Com.ViewPagerIndicator.

Kornelis commented 5 years ago

I had a similar issue. Downgrading the CircleIndicator Nuget Package helped as a Workaround.

hamid-shaikh commented 5 years ago

I had a similar issue. Downgrading the CircleIndicator Nuget Package helped as a Workaround.

There is no such package installed called CircleIndicator - I can only see package installed is CarouselView.FormsPlugin - Version 5.2.0

DoctorWaffles commented 5 years ago

I had a similar issue. Downgrading the CircleIndicator Nuget Package helped as a Workaround.

All version seems to break for me, what version of CircleIndicator and CarouselView were you using?

alexrainman commented 5 years ago

I am back! Releasing new version in the next 2 weeks. This issue will be corrected.

Phenek commented 5 years ago

@alexrainman Hope you will, cause we stuck with Xamarin 3.4 with your very useful lib.

tempest360 commented 5 years ago

@alexrainman any update on the new release ? It's been more than 3 weeks now. @Phenek has created a PR for the change. Thanks 👍

pandaloupe commented 5 years ago

My quick and dirty fix for this is clearing the content and thus all controls from the current page before switching to another main page. While this is surely not an elegant solution and leaves the page blank while initializing the new one at least the error is gone...

// clear the contents of the old page
var oldPage = Application.Current.MainPage;
if (oldPage is NavigationPage navPage)
{
   if (navPage.RootPage is ContentPage contentPage)
   {
      contentPage.Content = null;
   }
}

// now switch to your new page
Application.Current.MainPage = [your new page];
USAMA-app commented 5 years ago

I am back! Releasing new version in the next 2 weeks. This issue will be corrected.

any update of this issue.

alexrainman commented 5 years ago

Updating to latest version of CirclePageIndicator should solve this in the meantime.

Phenek commented 5 years ago

489

I updated CirclePageIndicator to 1.0.3 inside my project

Even if I install ViewPager I got the:

Can not resolve reference: Xamarin.Android.Support.ViewPager, referenced by Com.ViewPagerIndicator.

Unfortunately I think that there is already a CirclePageIndicator.dll in Carousel Lib

Updating the CirclePageIndicator inside the CarouselView nupkg is solved the issue for me.

Regards,

alexrainman commented 5 years ago

There's not a CirclePageIndicator.dll in Carousel Lib. You will have to wait for the next release then.

pandaloupe commented 5 years ago

Updating to latest version of CirclePageIndicator should solve this in the meantime.

@alexrainman Tying to do that, I get the same Error as @Phenek

Updating the CirclePageIndicator inside the CarouselView nupkg is solved the issue for me.

@Phenek How did you do that?

Nevertheless: Great tool, would always recommend it! 👍

Phenek commented 5 years ago

I just created a nuspec file with the updated circlepageIndicator PR and then nuget pack it to create .nupkg output

alexrainman commented 5 years ago

This will be fixed in next release.