Bug of build between ionic and android


#1

Hello Everyone !
I am working on a projet on Ionic In this project, i’m extracting datas from an xml with a home.ts file. And then I display those datas on the home.html. But i have a major problem : when i build my app using “ionic cordova build android” and then i install it on my Android phone the datas from the XML file are missing while they are on the page on ionic (“ionic serve -l”). Does everyone have a solution ? please :’(


#2

What is your ionic info output?
What is the code you use to extract this data?


#3

—> ionic info

cli packages: (C:\Users\Krzysztof\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.11.3
npm  : 3.10.10
OS   : Windows 10

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : legacy

—>home.ts

import { Component } from ‘@angular/core’;
import { NavController } from ‘ionic-angular’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;
import xml2js from ‘xml2js’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {

public xmlItems : any;

constructor(public navCtrl: NavController,
public http : Http)
{

}

ionViewWillEnter()
{
this.loadXML();
}

loadXML()
{
this.http.get(’/assets/data/maree.xml’)
.map(res => res.text())
.subscribe((data)=>
{
this.parseXML(data)
.then((data)=>
{
this.xmlItems = data;
});
});
}

parseXML(data)
{
return new Promise(resolve =>
{
var k,
arr = [],
parser = new xml2js.Parser(
{
trim: true,
explicitArray: true
});

     parser.parseString(data, function (err, result)
     {
        var obj=result.marees;
        for(k in obj.jour)
        {
           var item = obj.jour[k];
           arr.push({ 
			  date: item.date[0],
			  porte1: item.porte[0],
			  porte2: item.porte[1],
			  porte3: item.porte[2],
			  porte4: item.porte[3],
			  maree1: item.maree[0],
			  maree2: item.maree[1],
			  maree3: item.maree[2],
			  maree4: item.maree[3]
           });
        }

        resolve(arr);
     });
  });

}

}


#4

Maybe this is wrong in the built app?

Did you remote debug the problem on the device already? Follow these instructions here to debug the problem in Chrome dev tools: https://ionic.zone/debug/remote-debug-your-app#android Look at the console and network tabs for errors.