cancel
Showing results for 
Search instead for 
Did you mean: 

Model and Odata service not accessing from emulator.....

former_member213574
Participant
0 Kudos

Hi All,

While doing testing of our application which is accessing the odata service and getting the data from there, we are not able to experience the app in android emulator.

In the browser (chrome) the app is doing good and all the pages are loading. The app is able to connect the odata and storing the same in an array.

When we burn the same app to emulator, the line where we are storing the data to an array after accessing the odata is throwing error:

"08-28 14:57:36.444: E/Web Console(639): Uncaught TypeError: Cannot read property 'results' of undefined at file:///android_asset/sample_makit.html:2072"

that particular portion of code:

var oModel2= new sap.ui.model.odata.ODataModel("our url");

  sap.ui.getCore().setModel(oModel2);

  var TableData = new Array();

  TableData=oModel2.attachRequestCompleted(function(){oModel2.getProperty("/MeterReadingResults")});

  var auxArray = new Array(); 

   oModel2.read("/Devices('10010708')/MeterReadingResults", 

                       null, null, false, function(oData, oResponse){ 

             auxArray = oData; 

   });

  

   TableData=auxArray.results;

Kindly help me in this regard,

Regards,

Arun

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member213574
Participant
0 Kudos

Hi All,

For example please help me in converting the below code into android app. The code is just displaying the company name from odata service (northwind).

<!DOCTYPE html>

<html><head>

  <meta http-equiv='X-UA-Compatible' content='IE=edge' />

  <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

  <title>Table with OData Binding</title>

  <script id='sap-ui-bootstrap' type='text/javascript'

        src="resources/sap-ui-core.js"

        data-sap-ui-libs="sap.m,sap.ui.commons,sap.ui.table"

  data-sap-ui-theme="sap_bluecrystal"></script>

  <script>

  var oModel = new sap.ui.model.odata.ODataModel("http://services.odata.org/V3/Northwind/Northwind.svc/");  

  sap.ui.getCore().setModel(oModel); 

  var oText = new sap.ui.commons.TextView("l1", {text: "{CompanyName}"});  

  oText.bindElement("/Customers('ALFKI')"); 

  oText.placeAt("content");

  var app = new sap.m.App("myApp", {initialPage:"page1"});

  var page1 = new sap.m.Page("page1", {

        title: "TCS Power Network",

       content : [oText]

       

       

    });

  app.addPage(page1);

  app.placeAt("content");

</script>

</head>

<body class='sapUiBody'>

  <div id='content'></div>

</body>

</html>

Regards,

Arun

midhun_vp
Active Contributor
0 Kudos

I assume that you are developing a web application (not a cordova/hybrid app) using UI5. If you are running the app in the android default browser you may face some issues. UI5 best runs in chrome browser. So what I suggest is to install chrome in your android device/emulator and test.

To install chrome on emulator : if you don't have apk for chrome, install apk extractor app in a real android device >install chrome mobile app>use apk extractor app to get the apk file of chrome>send it to the laptop>install apk in emulator using the command line How do you install an APK file in the Android emulator? - Stack Overflow

Regards,

Midhun VP

former_member213574
Participant
0 Kudos

Hi Midhun,

No My problem is different,

I want to convert the web application to an android hybrid app.

As i told the application i developed is working fine in web application, as you suggested I am also using chrome to develop the same.

My next step is to convert the same into an hybrid app?

In order to understand that i posted the simple code for Northwind to convert to an app?

Could you please help in this regard?

Regards,

Arun

former_member213574
Participant
0 Kudos

Hi Midhun/All,

Could you please help me in proceeding further?

Regards,

Arun

midhun_vp
Active Contributor
0 Kudos

Use cordova to create a hybrid app. You can find many resources in web.

Regards,

Midhun VP

former_member213574
Participant
0 Kudos

Hi Midhun,

I was able to create normal hybrid app with the help of cordova.

But when the application is having any link or odata connection, it is not getting data from that link.

I am stuck in this point, could you please help.

Regards,

Arun