title: Ionic app working on web but not working on simulator or device
body: <p>I am developing a simple maid mobile application in Ionic. I have developed registration module and it's worked fine in web but when I try to build it in device or simulator it does not work. </p>
  
  <p><a href="https://i.stack.imgur.com/ilroF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ilroF.jpg" alt="I am getting this error when I run this command(ionic cordova run android --livereload"></a></p>
  
  <p><a href="https://i.stack.imgur.com/DFF2g.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DFF2g.jpg" alt="I am getting this error when I run this command(ionic cordova run android --livereload"></a></p>
  
  <p>when I run (ionic cordova run android) the app load in the simulator but it is not working accordingly which means when I enter users information and click submit the information is not loaded in the database but when I do the same thing in web(ionic serve) it works just fine and I could be able to register a new user into the database. I am using laravel for my backend. Please help me to solve this problem.</p>
  
  <p><strong>index.html</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  
  &lt;head&gt;
    
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;Ionic App&lt;/title&gt;
  
    &lt;base href="."/&gt;
  
    &lt;meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /&gt;
    &lt;meta name="format-detection" content="telephone=no" /&gt;
    &lt;meta name="msapplication-tap-highlight" content="no" /&gt;
  
  
    &lt;link rel="icon" type="image/png" href="assets/icon/favicon.png" /&gt;
    
  
    &lt;!-- add to homescreen for ios --&gt;
    &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
    &lt;meta name="apple-mobile-web-app-status-bar-style" content="black" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
    &lt;app-root&gt;&lt;/app-root&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>config.xml</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"&gt;
      &lt;name&gt;MyApp&lt;/name&gt;
      &lt;description&gt;An awesome Ionic/Cordova app.&lt;/description&gt;
      &lt;author email="hi@ionicframework.com" href="http://ionicframework.com/"&gt;Ionic Framework Team&lt;/author&gt;
      &lt;content src="index.html" /&gt;
      &lt;access origin="*" /&gt;
      &lt;allow-intent href="http://*/*" /&gt;
      &lt;allow-intent href="https://*/*" /&gt;
      &lt;allow-intent href="tel:*" /&gt;
      &lt;allow-intent href="sms:*" /&gt;
      &lt;allow-intent href="mailto:*" /&gt;
      &lt;allow-intent href="geo:*" /&gt;
      &lt;preference name="ScrollEnabled" value="false" /&gt;
      &lt;preference name="android-minSdkVersion" value="19" /&gt;
      &lt;preference name="BackupWebStorage" value="none" /&gt;
      &lt;preference name="SplashMaintainAspectRatio" value="true" /&gt;
      &lt;preference name="FadeSplashScreenDuration" value="300" /&gt;
      &lt;preference name="SplashShowOnlyFirstTime" value="false" /&gt;
      &lt;preference name="SplashScreen" value="screen" /&gt;
      &lt;preference name="SplashScreenDelay" value="3000" /&gt;
      &lt;platform name="android"&gt;
          &lt;edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"&gt;
              &lt;application android:networkSecurityConfig="@xml/network_security_config" /&gt;
              &lt;application android:usesCleartextTraffic="true" /&gt;
          &lt;/edit-config&gt;
          &lt;resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" /&gt;
          &lt;allow-intent href="market:*" /&gt;
          &lt;icon density="ldpi" src="resources\android\icon\drawable-ldpi-icon.png" /&gt;
          &lt;icon density="mdpi" src="resources\android\icon\drawable-mdpi-icon.png" /&gt;
          &lt;icon density="hdpi" src="resources\android\icon\drawable-hdpi-icon.png" /&gt;
          &lt;icon density="xhdpi" src="resources\android\icon\drawable-xhdpi-icon.png" /&gt;
          &lt;icon density="xxhdpi" src="resources\android\icon\drawable-xxhdpi-icon.png" /&gt;
          &lt;icon density="xxxhdpi" src="resources\android\icon\drawable-xxxhdpi-icon.png" /&gt;
          &lt;splash density="land-ldpi" src="resources\android\splash\drawable-land-ldpi-screen.png" /&gt;
          &lt;splash density="land-mdpi" src="resources\android\splash\drawable-land-mdpi-screen.png" /&gt;
          &lt;splash density="land-hdpi" src="resources\android\splash\drawable-land-hdpi-screen.png" /&gt;
          &lt;splash density="land-xhdpi" src="resources\android\splash\drawable-land-xhdpi-screen.png" /&gt;
          &lt;splash density="land-xxhdpi" src="resources\android\splash\drawable-land-xxhdpi-screen.png" /&gt;
          &lt;splash density="land-xxxhdpi" src="resources\android\splash\drawable-land-xxxhdpi-screen.png" /&gt;
          &lt;splash density="port-ldpi" src="resources\android\splash\drawable-port-ldpi-screen.png" /&gt;
          &lt;splash density="port-mdpi" src="resources\android\splash\drawable-port-mdpi-screen.png" /&gt;
          &lt;splash density="port-hdpi" src="resources\android\splash\drawable-port-hdpi-screen.png" /&gt;
          &lt;splash density="port-xhdpi" src="resources\android\splash\drawable-port-xhdpi-screen.png" /&gt;
          &lt;splash density="port-xxhdpi" src="resources\android\splash\drawable-port-xxhdpi-screen.png" /&gt;
          &lt;splash density="port-xxxhdpi" src="resources\android\splash\drawable-port-xxxhdpi-screen.png" /&gt;
      &lt;/platform&gt;
      &lt;platform name="ios"&gt;
          &lt;allow-intent href="itms:*" /&gt;
          &lt;allow-intent href="itms-apps:*" /&gt;
          &lt;icon height="57" src="resources/ios/icon/icon.png" width="57" /&gt;
          &lt;icon height="114" src="resources/ios/icon/icon@2x.png" width="114" /&gt;
          &lt;icon height="40" src="resources/ios/icon/icon-40.png" width="40" /&gt;
          &lt;icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" /&gt;
          &lt;icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" /&gt;
          &lt;icon height="50" src="resources/ios/icon/icon-50.png" width="50" /&gt;
          &lt;icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" /&gt;
          &lt;icon height="60" src="resources/ios/icon/icon-60.png" width="60" /&gt;
          &lt;icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" /&gt;
          &lt;icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" /&gt;
          &lt;icon height="72" src="resources/ios/icon/icon-72.png" width="72" /&gt;
          &lt;icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" /&gt;
          &lt;icon height="76" src="resources/ios/icon/icon-76.png" width="76" /&gt;
          &lt;icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" /&gt;
          &lt;icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" /&gt;
          &lt;icon height="29" src="resources/ios/icon/icon-small.png" width="29" /&gt;
          &lt;icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" /&gt;
          &lt;icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" /&gt;
          &lt;icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" /&gt;
          &lt;splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" /&gt;
          &lt;splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" /&gt;
          &lt;splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" /&gt;
          &lt;splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" /&gt;
          &lt;splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" /&gt;
          &lt;splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" /&gt;
          &lt;splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" /&gt;
          &lt;splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" /&gt;
          &lt;splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" /&gt;
          &lt;splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" /&gt;
          &lt;splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" /&gt;
          &lt;splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" /&gt;
          &lt;splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" /&gt;
      &lt;/platform&gt;
      &lt;plugin name="cordova-plugin-whitelist" spec="1.3.3" /&gt;
      &lt;plugin name="cordova-plugin-statusbar" spec="2.4.2" /&gt;
      &lt;plugin name="cordova-plugin-device" spec="2.0.2" /&gt;
      &lt;plugin name="cordova-plugin-splashscreen" spec="5.0.2" /&gt;
      &lt;plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" /&gt;
      &lt;plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" /&gt;
      &lt;plugin name="cordova-plugin-advanced-http" spec="^2.1.1"&gt;
          &lt;variable name="OKHTTP_VERSION" value="3.10.0" /&gt;
      &lt;/plugin&gt;
      &lt;engine name="browser" spec="^5.0.4" /&gt;
      &lt;engine name="android" spec="^7.1.4" /&gt;
  &lt;/widget&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>auth-service.ts</strong>
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Injectable, OnInit } from '@angular/core';
  import 'rxjs/add/operator/map';
  import { HTTP } from '@ionic-native/http/ngx';
  import {Headers, RequestOptions } from '@angular/http';
  import { HttpClient } from '@angular/common/http';
  
  const apiUrl = 'http://fypBackend.test/api/users';
  
  @Injectable({
    providedIn: 'root'
  })
  export class AuthServiceService implements OnInit {
    regData = {"name": "", "icNumber": "", "email": "", "password": "", "phone": "", "address": "", "cityState": "", "houseType": "", "category":""};
    data = {
      "name": this.regData.name,
      "icNumber": this.regData.icNumber,
      "email": this.regData.email,
      "password": this.regData.password,
      "phone": this.regData.phone,
      "address": this.regData.address,
      "cityState": this.regData.cityState,
      "houseType": this.regData.houseType,
      "category": this.regData.category
    };
  
    constructor(public http: HttpClient) { }
    ngOnInit(){}
  
    register(data){
      return new Promise(() =&gt; {
      let headers = new Headers();
      headers.append('Content-Type', 'application/json' );
      
      this.http.post(apiUrl, data)
      .subscribe(data =&gt; {
        console.log(data);
        console.log('Data inserted');
      }, error =&gt; {
       console.log(data.error);
       console.log(error);
       console.log(error.status);
       console.log(error.error); // error message as string
       console.log(error.headers);
       console.log('Not working')
     });
    })
  }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>register.ts</strong>
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Component} from '@angular/core';
  import { NavController,LoadingController, ToastController } from '@ionic/angular';
  import {AuthServiceService} from '../auth-service.service';
  import { AlertController } from '@ionic/angular';
  
  
  @Component({
    selector: 'page-register',
    templateUrl: './register.page.html',
    styleUrls: ['./register.page.scss'],
  })
  export class RegisterPage{
    loading: any;
    regData = {"name": "", "icNumber": "", "email": "", "password": "", "phone": "", "address": "", "cityState": "", "houseType": "", "category":""};
  
    constructor(public navCtrl: NavController, public authService: AuthServiceService, public loadingCtr: LoadingController, private toastCtrl: ToastController, public alertController:AlertController) { }
  
    doSignup(){
      this.authService.register(this.regData).then((result)=&gt;{
        this.presentAlertSuccess();
        console.log('Successful')
      }, (err) =&gt; {
        this.presentAlert(err);
        console.log("There is an error")
      });
    }
    async presentAlertSuccess(){
      const alert = await this.alertController.create({
        header: 'Alert',
        subHeader: 'Subtitle',
        message: 'Successful',
        buttons: ['OK']
      });
  
      await alert.present();
    }
    async presentAlert(msg){
      const alert = await this.alertController.create({
        header: 'Alert',
        subHeader: 'Subtitle',
        message: 'Not successful',
        buttons: ['OK']
      });
  
      await alert.present();
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>ionic information</strong>
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>Ionic:
  
     Ionic CLI                     : 5.2.1 (C:\Users\User\AppData\Roaming\npm\node_modules\ionic)
     Ionic Framework               : @ionic/angular 4.5.0
     @angular-devkit/build-angular : 0.13.9
     @angular-devkit/schematics    : 7.3.9
     @angular/cli                  : 7.3.9
     @ionic/angular-toolkit        : 1.5.1
  
  Cordova:
  
     Cordova CLI       : 8.1.2 (cordova-lib@8.1.1)
     Cordova Platforms : android 7.1.4, browser 5.0.4
     Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 6 other plugins)
  
  Utility:
  
     cordova-res : 0.3.0
     native-run  : 0.2.6
  
  System:
  
     Android SDK Tools : 26.0.2 (C:\Users\User\AppData\Local\Android\Sdk)
     NodeJS            : v10.3.0 (C:\Program Files\nodejs\node.exe)
     npm               : 6.1.0
     OS                : Windows 10</code></pre>
  </div>
  </div>
  </p>