alexrainman / CarouselView

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

DisplayAlert doesn't work after installing this plugin #51

Closed abdu292 closed 7 years ago

abdu292 commented 7 years ago

I see "DisplayAlert" throws the below error after installing this plugin. I am using .NET Standard 1.4.

To re-produce the issue download this sample project here then install the "CarouselView.FormsPlugin"plugin on to both main client & droid projects. After doing all the steps for the plugin try adding a "DisplayAlert" somewhere.


Unhandled Exception:

Java.Lang.NullPointerException: Attempt to invoke virtual method 'void android.view.ViewGroup.setVisibility(int)' on a null object reference occurred
alexrainman commented 7 years ago

The plugin is not supported on .Net Standards, yet ...

abdu292 commented 7 years ago

Thanks @alexrainman. In reality the real "Carousel" functionality works very well, but this is the extra problem I experience. So are you affirming this is because of .NET standard being a "not supported" library yet?

I doubt, because if this is an issue as you say, then the nuget installation should throw a "compatibility" error right a way saving us some time. Now that I integrated this plugin fully on my app and was thinking the errors with "DisplayAlert" are something else. Thank you for your plugin and I understand you are helping the community. Also just wondering if any work around you can think of?

alexrainman commented 7 years ago

Sometimes PCL plugins install and work well on .net standards. Thanks for letting me know.

About the compatibility problem with DisplayAlert? I recommend you to use Acr.UserDialogs instead. Let me know if that solves the problem.

abdu292 commented 7 years ago

Thanks @alexrainman . This issue is resolved by downgrading the version of Xamarin.Forms (2.3.3.180 => 2.3.2.127). This works now, however not sure about the future in case I need to use later version of Xamarin.Forms.

alexrainman commented 7 years ago

Can you share a demo project reproducing the issue?

abdu292 commented 7 years ago

Thanks @alexrainman . Steps & a project are provided in my first post, if you haven't noticed already. Thanks!

abdu292 commented 7 years ago

@alexrainman Did you get a chance yet to look on to this? The other option we have is to use Xamarin's official Carousel View but this still has issues. I tried integrating that first but is very sensitive when adding a WebView in it and the vertical scroll doesn't work really well. In their roadmap the official CarouselView will be stable only by Feb 2017 (tentative).

alexrainman commented 7 years ago

I believe the problem is not the plugin itself but Xamarin.Forms latest version compatibility issue with .Net Standards.

I also believe it's too soon to migrate to .Net Standards. Just a little percent of the libraries and plugins already have support for it and you will encounter this kind of problem very often.

alexrainman commented 7 years ago

Also, if DisplayAlert doesn't works, i advice to use Acr.UserDialogs as a really great Dialog Service library. You can call it from anywhere, including ViewModels.

alexrainman commented 7 years ago

To be fare, i never used DisplayAlert myself :)

abdu292 commented 7 years ago

Thanks @alexrainman . Yeah, I integrated "Acr.UserDialogs" after your advice. However I was already facing another "Activity Destroyed" issue with the latest version or Xamarin plus NavigationPage and that's where I thought to downgrade my Xamarin.Forms. To reproduce - try exiting the app using the back button on an android device or emulator.

alexrainman commented 7 years ago

I believe its because the plugin is not .Net Standards. I am trying to find the way on how to release the plugin with .Net Standards support and PCL at the same time.

alexrainman commented 7 years ago

I believe the problem you are having is between .Net Standards and Xamarin.Forms.

alexrainman commented 7 years ago

I cannot build your project. Lots of errors.

abdu292 commented 7 years ago

@alexrainman I see. Actually that's a working project. Not sure what error you get. Also, Apologize. I think the activity destroyed issue is with the "NavigationPage" and latest version of Xamarin.Forms, but I don't remember well. I will try re-producing when I get a chance (Updated the above comment as well)

alexrainman commented 7 years ago

Do you use Windows or Mac?

abdu292 commented 7 years ago

Ofcourse Windows 10 with Visual Studio 2017 RC

abdu292 commented 7 years ago

@alexrainman Just confirmed. "Activity destroyed" issue has nothing to do with this plugin, but "DisplayAlert" indeed breaks.

abdu292 commented 7 years ago

Closed by mistake.

alexrainman commented 7 years ago

Do you want some advice? I know its tentative using latest software releases, like VS 2017 and .Net Standards, but if you want some stability, dont use RC candidate software. Go back to Stable release of VS 2015 and old PCL. I promise you wont have any issue.

abdu292 commented 7 years ago

@alexrainman I want to use EF Core, which cannot be used with PCL. Also, I strongly believe VS 2017 is just tooling and has no impact on the library. I still can spin up a VM on my azure with VS 2015 to see if that's not the case. I am unsure if this issue can be closed in this state!

alexrainman commented 7 years ago

As i said before, the library is not .Net Standards compatible. I dont have any problem with latest Xamarin.Forms and DisplayAlert if i use it from PCL and stable tools, that can introduce compiling anf compatibility issues

abdu292 commented 7 years ago

Okay. Got it. Thank you! I think I will try for official CarouselView and will try some workaround with it's stability issue as I use .NET standard Libraries.

alexrainman commented 7 years ago

I am planning to release .Net Standards compatility but for now its not :)

abdu292 commented 7 years ago

I tested on another Xamarin.Forms project that uses normal PCL and we still have this issue with DisplayAlert. Tested multiple times by installing & uninstalling this plugin. So, I believe this issue is not related to .NET standards.

alexrainman commented 7 years ago

Let me check it out.

alexrainman commented 7 years ago

@abdu292 I know why is crashing on you. You are missing calling Init() after Forms.Init()

global::Xamarin.Forms.Forms.Init(this, bundle);
CarouselViewRenderer.Init();

So, the plugin doesn't have any issue. Is up to you to use it or no 👍

abdu292 commented 7 years ago

@alexrainman I indeed included "Init" method in the droid project as it is pretty clear in the set-up section. I will try re-creating this for you in a small demo project. Thank you for taking time to respond.

alexrainman commented 7 years ago

I tried and i forgot to include Init method and i was having same issue as you. Once i added Init the issue is gone.

abdu292 commented 7 years ago

I see. I am unsure what else I am missing. I will try creating a small re-pro.

alexrainman commented 7 years ago

Ok

abdu292 commented 7 years ago

@alexrainman It doesn't look like this issue exists any more. All works well now. Thanks a bunch!

alexrainman commented 7 years ago

If my work is helping you, please help me back: https://xamarinhq.wufoo.com/forms/nominate-a-xamarin-mvp/

alexrainman commented 7 years ago

This is what i have done that is community visible:

dpalat commented 6 years ago

@abdu292 I fixed this issue in Android by only removing "CarouselViewRenderer.Init();" because sometimes it is not necessary to do so, both plugins work well ACR Dialog and CarouselView. Maybe it can work for you too.