I am having an issue with the Router on android, i am receiving a “Object reference was null” error on router.goto(“login”). It works fine on IOS and the preview. Not sure what’s going on.
Main View
<App>
<Router ux:Name="router" />
<JavaScript File="main.js" />
<StatusBarBackground Alignment="Top"/>
<Navigator DefaultTemplate="main">
<LoginView router="router" ux:Template="login" />
<ux:Include File="Resources.ux" />
<ClientPanel Color="Red" ux:Template="main" >
<Translation ux:Name="mainAppTranslation" />
<Panel Dock="Top" Height="50" Margin="5">
<Image ux:Name="logo" File="Icons/logo2.png" Width="40%" Alignment="Center"/>
<Image File="Assets/search.png" Color="MainView.White" Width="30" Height="30" Margin="10"
Alignment="CenterRight"/>
</Panel>
<ux:Include File="MenuPanel.ux" />
<PageControl ux:Name="nav" Active="{currentPage}" Color="MainView.White">
<NavigationMotion GotoEasing="BackOut" />
<Attractor ux:Name="indicatorColorAttractor" Target="indicator.Color" Value="color0" />
<Rectangle ux:Name="bgColor" Layer="Background" Color="MainView.White" Opacity="0.10"/>
<Attractor ux:Name="bgColorAttractor" Target="bgColor.Color" Value="color0" />
<WhileTrue ux:Name="shrinkIndicatorWidth">
<Change indicator.Width="90" Duration="0.25"/>
</WhileTrue>
<Image ux:Class="PagePlaceholder" Margin="8,10,8,0" StretchMode="UniformToFill" ContentAlignment="Top"/>
<ux:Include File="PostPage.ux" />
<ux:Include File="CategoryPage.ux" />
<ux:Include File="MessagePage.ux" />
<ux:Include File="ProfilePage.ux" />
<!-- <ux:Include File="DetailsPage.ux" /> -->
</PageControl>
</ClientPanel>
</Navigator>
</App>
Login View
<Panel Color="MainView.Red" ux:Class="LoginView">
<Router ux:Dependency="router" />
<ux:Include File="StateAnimation.ux" />
<!-- Signup Form-->
<HidingPanel ux:Name="signupForm" Width="90%" Height="50%" Offset="0%,10%">
<Grid RowCount="4" Margin="30,40,30,60">
<TextInput ux:Name="registerEmail" Value="{registerEmail}" PlaceholderText="Email" Opacity="1" Alignment="VerticalCenter" PlaceholderColor="#888" />
<TextInput ux:Name="registerPassword" Value="{registerPassword}" PlaceholderText="Password" IsPassword="true" Opacity="1" Alignment="VerticalCenter" PlaceholderColor="#888" />
<TextInput ux:Name="registerFirstName" Value="{registerFirstName}" PlaceholderText="First Name" Opacity="1" Alignment="VerticalCenter" PlaceholderColor="#888" />
<TextInput ux:Name="registerLastName" Value="{registerLastName}" PlaceholderText="Last Name" Opacity="1" Alignment="VerticalCenter" PlaceholderColor="#888" />
</Grid>
<WhileEnabled>
<Change registerEmail.Opacity="1" Duration="0.4" />
<Change registerPassword.Opacity="1" Duration="0.4" Delay="0.15" />
<Change registerFirstName.Opacity="1" Duration="0.4" Delay="0.3" />
<Change registerLastName.Opacity="1" Duration="0.4" Delay="0.3" />
</WhileEnabled>
<Panel>
<Panel ux:Name="submitButton" Width="200" Offset="0%,50%" Height="50" HitTestMode="LocalBoundsAndChildren" Clicked="{register}">
<Text Value="REGISTER" Alignment="Center" TextColor="MainView.White" />
</Panel>
<Panel ux:Name="submitButtonCollapsed" Width="10" Offset="0%,50%" Height="10" />
</Panel>
<Panel>
<!-- <Panel ux:Name="loginBack" Width="200" Offset="0%,50%" Height="50" HitTestMode="LocalBoundsAndChildren" >
<Text Value="LOG IN" Alignment="Center" TextColor="MainView.White" />
<Clicked>
<Set state.Active="loginButtonState" />
</Clicked>
</Panel> -->
</Panel>
</HidingPanel>
<TextInput ux:Class="WhiteText" TextColor="MainView.White" FontSize="18" Alignment="VerticalCenter" PlaceholderColor="#ffffff80" />
<HidingPanel ux:Name="startPanel" Alignment="Bottom" Height="65%" Padding="15,0,15,15">
<!-- <GridLayout Rows="1*,15,15"/> -->
<DockPanel Alignment="Bottom">
<StackPanel>
<Grid RowCount="2" Margin="30,0,30,40" CellSpacing="14">
<WhiteText ux:Name="loginEmail" PlaceholderText="Email" Value="{loginEmail}" />
<WhiteText ux:Name="loginPassword" PlaceholderText="Password" IsPassword="true" Value="{loginPassword}" />
</Grid>
<WhileEnabled>
<Change loginEmail.Opacity="1" Duration="0.4" Delay="0.15" />
<Change loginPassword.Opacity="1" Duration="0.4" Delay="0.3" />
</WhileEnabled>
<Rectangle ux:Name="whiteRectLogin" Color="#5E2E91" LayoutMaster="loginButton" Layer="Background" CornerRadius="25" />
<Panel ux:Name="loginButton" Height="50" HitTestMode="LocalBounds" Margin="30,0,30,10" Clicked="{login}">
<Text Value="LOG IN" Alignment="Center" TextColor="#fff" HitTestMode="LocalBounds" />
</Panel>
<Panel ux:Name="signupButton" Height="50" HitTestMode="LocalBounds" Margin="30,0,30,40">
<Text Value="SIGN UP" Alignment="Center" TextColor="#5E2E91" HitTestMode="LocalBounds" />
<Clicked>
<Set state.Active="signupFormState" />
<!-- <Set state.Active="{loginViewState}" /> -->
</Clicked>
</Panel>
</StackPanel>
</DockPanel>
<!-- <Rectangle Color="BottomGray" Height="2" Width="55%"/>
<Rectangle Color="BottomGray" Height="2" Width="30%"/> -->
</HidingPanel>
<Panel ux:Name="addButtonPanel">
<HidingPanel ux:Name="addButton" Width="50" Height="50" Alignment="BottomRight" Margin="40" HitTestMode="LocalBoundsAndChildren">
<Text Value="+" FontSize="30" TextColor="MainView.White" Alignment="Center" />
</HidingPanel>
<Rectangle ux:Name="greenRect" Color="#5E2E91" LayoutMaster="submitButtonCollapsed" CornerRadius="25" Opacity="0">
<DropShadow />
<WhileTrue ux:Name="showGreenRect">
<Change greenRect.Opacity="1" Duration="0.2" />
</WhileTrue>
</Rectangle>
</Panel>
<Rectangle ux:Name="whiteRect" Color="MainView.White" LayoutMaster="signupButton" Layer="Background" CornerRadius="25" />
<Attractor ux:Name="whiteRectCornerRadiusAttractor" Target="whiteRect.CornerRadius" Value="25" Type="SmoothSnap" Unit="Points" />
<!-- Logo Panel -->
<HidingPanel ux:Name="logoPanel" Alignment="Top" Height="35%" IsEnabled="true" Layer="Background">
<DockPanel Alignment="Top">
<Panel Dock="Right" HitTestMode="LocalBoundsAndChildren" Clicked="{closeLogin}">
<Image File="Icons/close.png" Width="30" Height="30" />
</Panel>
</DockPanel>
<StackPanel Alignment="Bottom">
<Image ux:Name="logo_login" File="Icons/logo2.png" Width="50%" />
<StackPanel ux:Name="logoMockText">
<Rectangle Color="#fff" Width="60%" Height="5" CornerRadius="5" Margin="0,30,0,0" />
<Text Color="#fff" Margin="0,16,0,0" Value="Buy And Sell Easy" Alignment="Center" />
<!-- <Rectangle Color="#fff" Width="50%" Height="5" CornerRadius="5" Margin="0,16,0,0"/> -->
</StackPanel>
</StackPanel>
<WhileTrue ux:Name="moveLogo">
<Change logoMockText.Opacity="0" Duration="0.4" />
<Move Target="logo_login" Y="-0.6" RelativeTo="Size" Duration="0.5" Delay="0.3" Easing="CubicInOut" />
</WhileTrue>
<WhileKeyboardVisible>
<Change logoPanel.IsEnabled="false" />
</WhileKeyboardVisible>
</HidingPanel>
</Panel>
main.js
var goToLoginPage = function(){
if(Parse.User.current()){
var pic = "https://s3.amazonaws.com/ckrone/default_user.png";
if(Parse.User.current().get("picture")){
pic = Parse.User.current().get("picture").url();
}
currentUser.value = {
"firstName": Parse.User.current().get("firstName"),
"picture": pic
};
// = Parse.User.current();
debug_log(JSON.stringify(currentUser.value));
currentPage.value = "profilePage";
} else {
router.goto("login");
}
};
The app is crashing on router.goto(“login”)