Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] Fix previewer exceptions with shell #5955

Merged
merged 4 commits into from
May 2, 2019
Merged

Conversation

PureWeen
Copy link
Contributor

@PureWeen PureWeen commented Apr 18, 2019

Description of Change

This is a WIP but its purpose was to get through all the Forms SDK exceptions to the point where the previewer would just run shell or not

Current exception coming from previewer

[2019-04-18 16:32:31.5] ERROR: : The renderer encountered an error while rendering this file: System.NullReferenceException: Object reference not set to an instance of an object
Xamarin.Forms.Previewer.XamarinFormsLoaderAndroid.GetViewGroup (System.Object renderer)
AndroidFormsRendering.XFPageRendererView.SetupView (MonoTouch.Design.XamlRenderContext xamlContext)
AndroidFormsRendering.XFPageRendererView.Initialize (System.String xamlId)

[2019-04-18 16:32:31.5] ERROR: : AndroidXamlRenderer had a rendering error: System.NullReferenceException: Object reference not set to an instance of an object
Xamarin.Forms.Previewer.XamarinFormsLoaderAndroid.GetViewGroup (System.Object renderer)
AndroidFormsRendering.XFPageRendererView.SetupView (MonoTouch.Design.XamlRenderContext xamlContext)
AndroidFormsRendering.XFPageRendererView.Initialize (System.String xamlId)

Issues Resolved

API Changes

None

Platforms Affected

  • Core/XAML (all platforms)
  • iOS
  • Android
  • UWP

Behavioral/Visual Changes

None

Before/After Screenshots

Not applicable

Testing Procedure

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

VS bug #854002

@PureWeen PureWeen changed the base branch from master to 4.0.0 April 18, 2019 22:26
@PureWeen PureWeen added the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Apr 22, 2019
@PureWeen
Copy link
Contributor Author

@garuma the other area I'm not sure about is how to use a FragmentManager when running as designer

the context type provided from designer is

com.android.layoutlib.bridge.android.BridgeContext

Shell/TabbedPage/MDP all retrieve the SupportFragmentManager from the ACtivity

private FragmentManager FragmentManager => ((FormsAppCompatActivity)AndroidContext.GetActivity()).SupportFragmentManager;

and that's how they load the content

but I don't have a fragment activity when executing under the context of designer. Is there another approach we can take that's designer friendly?

@PureWeen PureWeen force-pushed the shell_previewer branch 2 times, most recently from b003a78 to b1fde66 Compare April 29, 2019 17:15
@samhouts samhouts added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Apr 29, 2019
@samhouts samhouts requested review from rmarinho and removed request for kingces95 April 29, 2019 17:46
@samhouts samhouts assigned rmarinho and unassigned kingces95 Apr 29, 2019
@PureWeen PureWeen marked this pull request as ready for review April 29, 2019 23:48
@PureWeen PureWeen removed the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Apr 29, 2019
@PureWeen
Copy link
Contributor Author

Alright this PR gets rid of all the exceptions with shell and previewer but it's still displaying a blank page most likely because of these errors

[2019-04-29 16:03:53.9] Renderer >> Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
[2019-04-29 16:03:52.6] Renderer >> ERROR: An exception occured while loading control android.support.design.widget.AppBarLayout
[2019-04-29 16:03:52.7] Renderer >> ERROR: java.lang.reflect.InvocationTargetException

I'm thinking we need to either theme wrap our controls when using previewer or previewer needs to use an appcompat theme

for now we can at least review and merge this PR into 4.0.0 to fix the exceptions

@PureWeen PureWeen added the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Apr 30, 2019
@PureWeen
Copy link
Contributor Author

Once I activated the appcompat theme for this previewer started throwing a whole new set of exceptions

so I set this to DNM for now

@PureWeen PureWeen removed the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Apr 30, 2019
@PureWeen
Copy link
Contributor Author

alright @samhouts @rmarinho this one is ready to go (Android only)

you should see a glorious blank page when loading a shell page into previewer.

Once we get appcompat enabled that should also load as blank as well

Copy link

@drewgillies drewgillies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lgtm--one line to look at though.

@PureWeen PureWeen requested a review from drewgillies May 1, 2019 17:39
@PureWeen PureWeen changed the title first set of changes to stop exceptions in previewer with Shell [Android] Fix previewer exceptions with shell May 2, 2019
@rmarinho rmarinho merged commit 8a7ee86 into 4.0.0 May 2, 2019
@samhouts samhouts deleted the shell_previewer branch May 7, 2019 17:36
@samhouts samhouts added this to the 4.0.0 milestone May 10, 2019
@samhouts samhouts added the approved Has two approvals, no pending reviews, and no changes requested label Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/shell 🐚 approved Has two approvals, no pending reviews, and no changes requested blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. e/6 🕕 6 forms-previewer p/Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants