when ı build my app and run on my real android device, (first page is login page) at first run, translate.use() gives me this error: {code:2, source:Native, exception:null}. if ı need to fix this, ı need to login first, ı login and redirect to inside page(root changing), then ı close app and reopen again, then my translate.use works fine. if I dont login (dont change root), even if ı close and open app again and again(without changing root), translate.use() never works.
And if ı install app via terminal to my real device with this code: "ionic cordova run android --device", it just works fine, deosnt give me any error at all... but after ı build it with "ionic cordova build android --release" and make app and install it to my device, it gives me this error ı mentioned
And it just works on web without any problem
Expected behavior
How do you think that we should fix this?
Minimal reproduction of the problem with instructions
my app.module.ts:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import {HttpClient, HttpClientModule,HTTP_INTERCEPTORS} from '@angular/common/http'
import {HTTP} from '@ionic-native/http/ngx'
import { TokenInterceptorService } from './core/interceptors/TokenInterceptor.service';
import { NativeStorage } from '@ionic-native/native-storage/ngx';
import { IonicStorageModule } from '@ionic/storage';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatDialogModule} from '@angular/material/dialog';
import {MatButtonModule} from '@angular/material/button';
import {MatExpansionModule} from '@angular/material/expansion';
import {MatSelectModule} from '@angular/material/select';
import { MatCommonModule } from '@angular/material/core';
import {MatInputModule} from '@angular/material/input';
import { FormsModule } from '@angular/forms';
import {MatRadioModule} from '@angular/material/radio';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatTabsModule} from '@angular/material/tabs';
import {MatTableModule} from '@angular/material/table';
import { DatePipe } from '@angular/common';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HousekeepingrackComponent } from './core/components/alerts/housekeepingrack/housekeepingrack/housekeepingrack.component';
import { HousekeepingComponent } from './core/components/alerts/housekeeping/housekeeping.component';
import { SecurityComponent } from './core/components/alerts/security/security.component';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { IonicSelectableModule } from 'ionic-selectable';
import { EventService } from './core/services/event/Event.service';
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}
@NgModule({
declarations: [AppComponent,HousekeepingrackComponent,HousekeepingComponent,SecurityComponent],
entryComponents: [],
schemas:[CUSTOM_ELEMENTS_SCHEMA],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
HttpClientModule,
IonicStorageModule.forRoot(),
BrowserAnimationsModule,
MatDialogModule,
MatButtonModule,
MatExpansionModule,
MatSelectModule,
MatCommonModule,
MatInputModule,
FormsModule,
MatRadioModule,
MatCheckboxModule,
MatTabsModule,
MatTableModule,
IonicSelectableModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (HttpLoaderFactory),
deps: [HttpClient]
}
})
],
providers: [
StatusBar,
SplashScreen,
EventService,
TranslateService,
DatePipe,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
HTTP,
{
provide:HTTP_INTERCEPTORS,
useClass:TokenInterceptorService,
multi:true
},
NativeStorage
],
bootstrap: [AppComponent]
})
export class AppModule {}
my app-rooting.module.ts:
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { LoginPageModule } from './pages/login/login.module';
const routes: Routes = [
{
path: 'login',
loadChildren: () => import('./pages/login/login.module').then( m => m.LoginPageModule),
},
{
path: 'traces/tracelist',
loadChildren: () => import('./pages/traces/traces.module').then( m => m.TracesPageModule)
},
{
path: 'housekeeping/housekeepingrack',
loadChildren: () => import('./pages/housekeepingrack/housekeepingrack.module').then( m => m.HousekeepingrackPageModule)
},
{
path: 'housekeeping/rooms',
loadChildren: () => import('./pages/housekeeping/housekeeping.module').then( m => m.HousekeepingPageModule)
},
{
path: 'operation/security',
loadChildren: () => import('./pages/security/security.module').then( m => m.SecurityPageModule)
},
{
path: 'profile/search',
loadChildren: () => import('./pages/profile/profile.module').then( m => m.ProfilePageModule)
},
{
path: 'profilemodal',
loadChildren: () => import('./modalpages/profilemodal/profilemodal.module').then( m => m.ProfilemodalPageModule)
},
{
path: 'main/dashboard',
loadChildren: () => import('./pages/dashboard/dashboard.module').then( m => m.DashboardPageModule)
},
{
path: 'guest-search',
loadChildren: () => import('./modalpages/guest-search/guest-search.module').then( m => m.GuestSearchPageModule)
},
{
path: 'activities',
loadChildren: () => import('./pages/activities/activities.module').then( m => m.ActivitiesPageModule)
},
{
path: 'reservation',
loadChildren: () => import('./modalpages/reservation/reservation.module').then( m => m.ReservationPageModule)
},
{
path: 'alakart-modal',
loadChildren: () => import('./pages/alakart-modal/alakart-modal.module').then( m => m.AlakartModalPageModule)
},
{
path: 'iframe',
loadChildren: () => import('./modalpages/iframe/iframe.module').then( m => m.IframePageModule)
},
{
path: 'options',
loadChildren: () => import('./pages/options/options.module').then( m => m.OptionsPageModule)
},
{
path: 'accounting',
loadChildren: () => import('./pages/accounting/accounting.module').then( m => m.AccountingPageModule)
},
//en sonda olması lazım, wildcard url requests için
{ path: '**', loadChildren: () => import('./pages/login/login.module').then( m => m.LoginPageModule) }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule {}
Current behavior
when ı build my app and run on my real android device, (first page is login page) at first run, translate.use() gives me this error: {code:2, source:Native, exception:null}. if ı need to fix this, ı need to login first, ı login and redirect to inside page(root changing), then ı close app and reopen again, then my translate.use works fine. if I dont login (dont change root), even if ı close and open app again and again(without changing root), translate.use() never works.
And if ı install app via terminal to my real device with this code: "ionic cordova run android --device", it just works fine, deosnt give me any error at all... but after ı build it with "ionic cordova build android --release" and make app and install it to my device, it gives me this error ı mentioned
And it just works on web without any problem
Expected behavior
How do you think that we should fix this?
Minimal reproduction of the problem with instructions
my app.module.ts:
my app-rooting.module.ts:
my app.component.ts:
my angular.json file:
Environment