This is a migrated thread and some comments may be shown as answers.

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

9 Answers 539 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Devon
Top achievements
Rank 1
Devon asked on 11 Jun 2013, 01:24 PM
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??

9 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 11 Jun 2013, 01:37 PM
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.
0
Devon
Top achievements
Rank 1
answered on 13 Jun 2013, 09:48 AM
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.
0
Steve
Telerik team
answered on 13 Jun 2013, 12:45 PM
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.
0
Devon
Top achievements
Rank 1
answered on 13 Jun 2013, 01:17 PM
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
0
Steve
Telerik team
answered on 13 Jun 2013, 02:02 PM
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.
0
Devon
Top achievements
Rank 1
answered on 13 Jun 2013, 03:53 PM
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.
0
Steve
Telerik team
answered on 13 Jun 2013, 04:04 PM
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.
0
Devon
Top achievements
Rank 1
answered on 13 Jun 2013, 04:29 PM
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!!

0
Accepted
Devon
Top achievements
Rank 1
answered on 13 Jun 2013, 05:47 PM
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
Tags
Apache Cordova
Asked by
Devon
Top achievements
Rank 1
Answers by
Steve
Telerik team
Devon
Top achievements
Rank 1
Share this question
or