I run ionic cordova run android
for my Ionic Cordova project. At this time, I have my mobile connected to PC via USB. So when I run that command, it installs th
I also faced this problem, but in my case, the problem is with default routing.
When App initializes it tries to open on default route that is Empty route, which further we redirect to the actual working route, In my case Empty route was redirected to "/dashboard".
Example code
const routes: Routes = [
{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full'
},
{
path: 'dashboard',
canActivate: [AuthGuard],
loadChildren: './home/home.module#HomePageModule'
},
{
path: 'login',
loadChildren: './public/login/login.module#LoginPageModule'
}
]
In the above code, my Empty route is redirecting to dashboard where [AuthGuard] is active, and it stuck in circulation, So I decided it redirect to the route where [AuthGuard] is not active, That is "/login" in my case. Updated code by redirecting to login where [Authgaurd] is not active.
const routes: Routes = [
{
path: '',
redirectTo: 'login',
pathMatch: 'full'
},
{
path: 'dashboard',
canActivate: [AuthGuard],
loadChildren: './home/home.module#HomePageModule'
},
{
path: 'login',
loadChildren: './public/login/login.module#LoginPageModule'
}
]
After building the project for Andriod, The app runs successfully.
Justed posted the answer if anyone has this issue same like me on the same problem.