Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova Android Uncaught Function Error

I'm currently using PhoneGap 2.7.0 on my project and code runs without error on iOS.When I try to run the same code on android (with the exception of the Cordova javascript file, which I know is different for Android) I'm getting this error:

05-21 22:02:25.630    1663-1663/com.###.### D/Cordova: onPageFinished(file:///android_asset/www/index.html)
05-21 22:02:25.640    1663-1663/com.###.### D/CordovaLog: Uncaught Function required as first argument!
05-21 22:02:25.640    1663-1663/com.###.### E/Web Console: Uncaught Function required as first argument! at file:///android_asset/www/cordova-2.7.0.js:627

Here is the JavaScript I'm using in index.html:

<script type="text/javascript">
var app;
document.addEventListener("deviceready", function()
{
    app = new AppWrapper();
}, false);
</script>

I'm not sure what the issue is.I had this issue before but it has resolved itself in the past (black magic?).Any help would be greatly appreciated.

like image 657
Kyle Somogyi Avatar asked May 21 '13 22:05

Kyle Somogyi


1 Answers

After employing Ripple to debug this issue (highly recommended), I found a pointer to an undefined function being applied to an event listener (so, not specific to the deviceready call).

For future developers: check to make sure all of your "addEventListener" calls are pointing to existing functions. Seems obvious, but it happens.

like image 59
Kyle Somogyi Avatar answered Sep 21 '22 12:09

Kyle Somogyi