Software Archive
Read-only legacy content

Compiled code not working but ok in debug and App Preview

Nick_F_2
New Contributor III
1,520 Views

Ive written an app that tests perfectly under App Preview via Debug and App Preview via Push, however when I compile the app some of the functions do not work. There are no errors during compile and all plugins are loaded according to,the build success screen.

The app has a barcode scanner, it returns the scanned codedata in all test environments but fails once compiled, it doesn't display the captured barcode, completely at a loss. I'm using xdk barcode scanner function. XDK version 1995.

0 Kudos
22 Replies
PaulF_IntelCorp
Employee
1,369 Views

Try using the "debuggable" set to "true" option and debug the built app directly on device. See this page for some details on how to do that: https://software.intel.com/en-us/xdk/docs/intel-xdk-debug-and-test-overview#RemoteChromeDevTools

0 Kudos
Adam_G_
New Contributor I
1,369 Views

have you set the permissions on the project tab to allow access to the hardware your using (I don't know the project but I'm guessing camera access, plus local storage, and possibly image gallery access).  Also, depending on if the app is doing the barcode decoding locally or not; you might need to set website access permissions).  Best way to check is to look at the permissions of the original project and then make sure you have the same boxes checked. 

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Adam

Thanks for your response.

I cannot see where you would do this, and I have not had to do it before as starting the App from first install will ask about access to various hardware such as the camera.

Could you calcify please.

 

0 Kudos
Andrey_M_Intel
Employee
1,369 Views

The process of adding plugin is described here: https://software.intel.com/en-us/xdk/docs/adding-third-party-plugins-to-your-xdk-cordova-app in the section "Including a Cordova Plugin in Your Intel XDK App".

But I would recommend follow Paul's suggestion and build debuggable package, connect to it using Chrome from desctop and look into the xonsol for the errors. Permissions are not the only issues which might lead to different behaviour of app under App Preview Crosswalk and standalone apk. For example If you are on the windows, the AppPreviewCrosswwalk will not distinguish the case of the file name in your project while for apk it is important.

 

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Ok Thanks, I am getting an error in the debuggable version under Chrome.

Cannot load DevTools frontend from an untrusted origin?remoteFrontend=true&dockSide=undocked&toolbarColor=rgba(230,230,230,1)&textColor=rgba(0,0,0,1)

Cannot get any further.

0 Kudos
PaulF_IntelCorp
Employee
1,369 Views

Can you provide an example APK built for Crosswalk that is set to debuggable equals true and generates this error message? I'd like to see the error message, that message smells like something about your system and not the Android device...

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul
I have PM'd you with the APK's.

Thanks

0 Kudos
PaulF_IntelCorp
Employee
1,369 Views

Nick, you did not set "debuggable" to "true" so I cannot connect to this APK over the USB using remote CDT. Please see this doc > https://software.intel.com/en-us/xdk/docs/intel-xdk-debug-and-test-overview#RemoteChromeDevTools

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul

I had set it to true, see code below, but somewhere during compile or config change a second entry was added turning back to false.

<!-- Change the debuggable preference to true to build a remote CDT debuggable app for -->
<!-- Crosswalk apps on Android 4.0+ devices and Cordova apps on Android 4.4+ devices. -->
<preference name="debuggable" value=“true” />
<!-- IMPORTANT: set the debuggable preference to false before you build for the store! -->

<!-- 'value' = number of milliseconds to display the splash screen in a Cordova build. -->
<!-- This preference only affects Cordova builds for Crosswalk and Android. -->
<!-- <preference name="SplashScreenDelay" value="2000" /> -->
<preference name="debuggable" value=“false” />
<icon platform="ios" src="images/72x72.png" width="72" height="72" />
<icon platform="ios" src="images/57x57.png" width="57" height="57" />
<icon platform="ios" src="images/40x40.png" width="40" height="40" />
<icon platform="ios" src="images/50x50.png" width="50" height="50" />
<icon platform="ios" src="images/80x80.png" width="80" height="80" />
<icon platform="ios" src="images/120x120.png" width="120" height="120" />
<icon platform="ios" src="images/29x29.png" width="29" height="29" />
<icon platform="ios" src="images/58x58.png" width="58" height="58" />
 

I will compile again and send over. Sorry about that.

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul
New PM sent
Thanks

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul
Found a bug in the app.js file where I split a string to write to an input field, this is not the cause of the problem, it was a change I made without fully testing.
I can send new copies if required.

0 Kudos
PaulF_IntelCorp
Employee
1,369 Views

Are you able to debug your built app on-device using Chrome now? See the doc link I sent in an earlier message.

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

yes think so. After hours now, so will test again tomorrow. Thanks

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul
I'm still having issues, when the Barcode scanner event fires it should move to a new page to display the captured code and allow the user to select some additional information.

On both Android and iPhone it fails trying to load the additional information from a mysql database with Failed to load resource: the server responded with a status of 404 (Not Found). This is a URL to my asp.net script which returns JSON data.

In App Preview it selects the data from mysql correctly and creates the list for the user correctly and display the next page. Once compiled it fails to load the data and move to the next page.

I use the following code to change to the page to display the data, af.ui.loadContent("uib_page_3",false,false,"slide"); I have also tried $.ui.loadContent("uib_page_3",false,false,"slide");
 

My code to get the additional info is


function getEvents() {
    //console.log("Getting Trackers for "+myuser+" from "+dbname);
    $.ajax({
        type: "POST",
        url: "<MYURL>/getEvents",
        data: "{'db':'" + localStorage.getItem("companyid") + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: true,
        crossDomain: true,
        success: function(json){
        jsonArray = $.parseJSON(json.d);
            $("#events").empty();
                       var html = "<div class='table-thing with-label widget uib_w_60 d-margins SelectWidth' data-uib='app_framework/select' data-ver='1'><select  style='width: 250px;' class='wide-control' id='teams' placeholder='Select'><option>None</option>";
             for(i=0; i < jsonArray.length; i++)
                       {
                       buttonID = jsonArray.ID;
                       buttonName = jsonArray.tButtonName;
                       html += "<option value='"+buttonName+"'>"+buttonName+"</option>";
                       }
             html += "</select></div>"
            $(html).appendTo("#events");
            af.ui.loadContent("uib_page_3",false,false,"slide");
        },
        error: function(msg) {
        navigator.notification.alert("Error:" + msg.d);
        }
    });
return false;
}

On both Android and iPhone it jumps to the Error: and displays the Alert because it cannot find the URL specified.
If I enter MYURL directly into the browser on either device I can retrieve the JSON data without issue.
Both devices are connected to the internet via Wifi.

0 Kudos
PaulF_IntelCorp
Employee
1,369 Views

Check the "Domain List" settings in the "Build Settings" on the "Projects" tab. It's probably blank and needs to either be set to '*' to allow the whole world or set to your domain.

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

No tried that as still no difference.

The frustrating thing is I have apps developed in XDK that talk to MySQL perfectly well via PHP and ASP.NET, but this app refuses point blank to work and I have idea why. I have used xhr and ajax both with excellent speed and results on my previous apps.

All the debug environments are working and JSON data is returned as expected but once compiled the devices refuse to see the URL web service from within the app.

0 Kudos
PaulF_IntelCorp
Employee
1,369 Views

One of my colleagues is trying to track down some AJAX issues that have been showing up when you build with CLI 4.1.2 (which uses Cordova 3.6 on Android and iOS). The current version of App Preview uses Cordova framework 3.5. She may try to contact you on this thread.

If you try building with CLI 3.5 do you get the same errors?

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul

How do I change the CLI version on build.

Thanks

0 Kudos
Nick_F_2
New Contributor III
1,369 Views

Hi Paul

Ignore that last question please. I'll let you know how it goes.

Thanks

0 Kudos
Nick_F_2
New Contributor III
1,251 Views

I have changed the CLI version to 3.5 in the Projects tab and this has not made any difference to the functionality.

0 Kudos
Reply