ERROR: Attempting to call cordova.exec() before 'deviceready'. Ignoring.

10 posts, 1 answers
  1. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 11 Jun 2013 Link to this post

    Hi there guys.

    I'm messing around with my brother's trial version of Icenium Graphite and I've run into the following issue...

    I created a new multi-platfrom cordova application. Ive built it using phonegap build and deployed it to a device but I'm getting the above error when I start the application, and when I try use the barcodeScanner plugin.

    Does anyone perhaps know why??
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 11 Jun 2013 Link to this post

    Hello Devon,

    Phonegap Build is a 3rd party service similar to what Icenium is and you should contact their support for problems you've encountered with it. Here are some threads that elaborate on the error you've hit:
    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  3. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 13 Jun 2013 Link to this post

    Hi Steve...

    I did come across those links and it seems like it has something to do with the versions of cordova.js in the project, but Icenium inserts both android and ios versions of the cordova.js files when you create the project so I assume it's inserting the correct versions of the files.

    Downloaded your barcodescanner sample app and tried to emulate that in my application structure but I'm still having this issue. I even copied the code within both the cordova.js files in the barcodescanner sample and put it into the files in my app but no change.

    It only happens when the app is deployed to a device or run on the device through Icenium. It works perfectly in the Icenium simulator.

    I've attached my index.html and index.js files for your consideration.

    Regards,
    Devon Britton.
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Jun 2013 Link to this post

    Hello Devon,

    According to those articles, this problem was specific to an earlier version of Cordova and yes, when you create a new Icenium project, we insert the correct versions of Cordova depending on your target version (min version is Cordova 2.0). The Bardcode scanner sample works correctly with Cordova 2.x version and we do not get any errors on the tested devices. Do you run the demo as it is without any modifications? What is the target Cordova version, device model and OS version?

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  5. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 13 Jun 2013 Link to this post

    You are quite welcome to give me the moron of the week award...

    I had another cordova.js file in my scripts folder and I was referencing that one instead of the one created when I created the project in Icenium.

    I'm still having a problem getting the barcodescanner to work however.

    I've tried the following 2 code segments and neither of them works. Nothing happens in the deployed app.

    I put an following alert in the second code segment - alert(window.plugins.barcodeScanner) and it returned "undefined".

    I am referencing my <script src="scripts/barcodescanner.js"></script> in my index.html page.

    function captureBarcode()
            {
                var scanner = cordova.require("cordova/plugin/BarcodeScanner");
                scanner.scan(
                function (result)
                {
                    alert("We got a barcode\n" +
                    "Result: " + result.text + "\n" +
                    "Format: " + result.format + "\n" +
                    "Cancelled: " + result.cancelled);
                },
                function (error)
                {
                    alert("Scanning failed: " + error);
                });
            }

    function captureBarcode()
            {
            alert("Capture Barcode - Index");
                window.plugins.barcodeScanner.scan(
                function(result)
                {
                    if (!result.cancelled)
                    {
                        that._addMessageToLog(result.format + " | " + result.text);    
                    }
                },
                function(error)
                {
                    console.log("Scanning failed: " + error);
                });
                
                function addMessageToLog(message)
                 {
                    var that = this,
                    currentMessage = that.resultsField.innerHTML;        
                    that.resultsField.innerHTML = currentMessage + message + '<br />';
                 }
            }

    My project is available here if for your consideration...

    http://sdrv.ms/18BFKve
  6. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Jun 2013 Link to this post

    Hi Devon,

    None of the Cordova plug-ins would work in the Icenium simulator, you must run the app on actual device. See the following articles for more info about our Cordova plug-ins:

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  7. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 13 Jun 2013 Link to this post

    Hi Steven.

    As mentioned in my previous post. I have put the app onto a device and nothing happens when trying to invoke the barcodescanner.

    I'm not sure how to debug an application on the actual device so any help would be greatly appreciated.
  8. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 13 Jun 2013 Link to this post

    Hello Devon,

    Can you confirm that running the Barcode Scanner sample demo works for you i.e. the following sequence of actions: open Graphite -> Clone -> Sample Projects -> Barcode Scanner -> Clone -> Run on Device?

    If that works, then the problem is specific to your app and how you build it (presumably outside Icenium) and we can only guess what is wrong.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  9. Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 13 Jun 2013 Link to this post

    Hi Steven.

    Yes the barcodescanner sample app runs perfectly well when I follow that sequence. My application also runs when I simulate it on the device, but nothing happens when I press the scan button.

    I am building my app using phonegap build and both the deployed app buiklt through phonegap build AND my app when run on the device through Icenium behave in exactly the same manner so I don't think the issue is with the build process.

    As I say I am at a complete loss as to what is happening. I've tried everything. My code is here (http://sdrv.ms/18BFKve) and I would REALLY appreciate it if you could take a look and see if you can see what's wrong??

    Thanks so much!!

  10. Answer
    Devon
    Devon avatar
    28 posts
    Member since:
    Aug 2012

    Posted 13 Jun 2013 Link to this post

    It's working now.

    I went back to the code from your sample application and it started working. Not sure why it didn't work before.

    Thanks for the help
Back to Top