I have an Android app built in Eclipse which uses Cordova 2.0.0. When built and loaded onto the phone using the Eclipse debugger the app works fine, but when I set android:debuggable="false" in the AndroidManifest file the jQuery.ajax() POST fails. I get nothing to tell me the failure reason in the LogCat trace.
Here's the jQuery.ajax call:
jQuery.ajax({
url: that.endpoint,
data: that.data,
dataType: "json",
type: "POST",
contentType: "application/json",
success: successHandler,
error: errorHandler,
timeout: serviceTimeout
});
When android:debuggable="true" it works fine and goes to the success handler, but when it android:debuggable="false" it goes to the failureHandler, with only textStatus set to "error" and nothing else to indicate why it failed. When it fails it appears that the post doesn't happen because I can see that it doesn't hit the webservice I am trying to call.
Does anyone have any ideas why the debuggable flag might be affecting my application in this way?
What else other than the logging level would the "debuggable" flag affect?
Any hints or pointers would be greatly appreciated.
Cheers
When you have your app set to debug=false that you must specify the URI from where the app is getting its data. When in debug mode your permissions are relaxed as opposed to not being in debug mode. See this reference: http://developer.android.com/guide/topics/providers/content-provider-basics.html#Permissions
Your code looks fine, and the fact that it only fails when set your app to the stricter debug=false tells me you don't have your URI permissions set up correctly. That's where I'd look first anyway.
Found the reason for this. My code was fine. The problem was with the SSL certificate of the webservice I was trying to call. Although my browser said it was ok, when I checked it with an SSL certificate checker (http://www.geocerts.com/ssl_checker for example) it showed me there was an issue with a certificate hierarchy. Fixing the certificate allowed my code to work.
I never had this problem with the iPhone version of the app so it seems that Android is more strict with it's SSL certificate checking (and it does no certificate checking when running in debug mode.)