WebView with Routing?

I am building a multi-page app using Navigator, I defined each page in its own UX file as ux:Class, like this:

<Page ux:Class="AboutPage">
    <Router ux:Dependency="router" />
    ...
</Page>

Then I integrated the WebView like this:

<Page ux:Class="AboutPage">
	<Router ux:Dependency="router" />
	<JavaScript>
            module.exports = {
                onPageLoaded : function(res) {
                    console.log("WebView arrived at "+ JSON.parse(res.json).url);
            }
        };
    </JavaScript>
    <DockPanel>
        <StatusBarBackground Dock="Top"/>
        <NativeViewHost>
            <WebView Dock="Fill" Url="http://www.google.com">
                <PageLoaded>
                    <EvaluateJS Handler="{onPageLoaded}">
                        var result = {
                            url : document.location.href
                        };
                        return result;
                    </EvaluateJS>
                </PageLoaded>
            </WebView>
        </NativeViewHost>

        <BottomBarBackground Dock="Bottom" />
    </DockPanel>
</Page>

Running on fuse simulator doesn’t show any error, but my app crashes as soon as I open it on an Android mobile device.

Any ideas why this is happening?

Thanks

Just to doublecheck: are you sure this is caused by the WebView? That is: have you verified that the crash goes away if the WebView is removed from the app?

Also: does the problem occur in both device preview and regular build on Android?

It’s quite likely that the Android logs contain relevant info here. If you start the app from terminal (like fuse build -tandroid -r) then you can see what the logs contain when the crash occurs (and share it with us). :slight_smile:

Yes the crash goes away when I remove WebView from my app.

The app failed to launch both in device preview and regular build on Android.

Here’s a strange thing though - the error on my Android Device disappeared when I tried to build my app from a new computer that I configured with Fuse. Since it worked on the new computer setup, I thought well I should try and re-install Fuse on the computer where it initially didn’t work - and the re-install fixed my WebView problem.

Hmm, that’s very strange. Was it the same Fuse version re-installed, or did you upgrade at the same time?

Either way, I’m happy it worked out for you!