0

Problem: I can see the URL opens in Android browser but phonegap app always says A network error occurred.

I had seen reference to this question at multiple locations, tried every solution I encountered and still didn't find a solution. I am trying to load a webpage served by intranet into phonegap app on android using following code:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.init();
    //WebView.enablePlatformNotifications(); // Enable proxy
    //setContentView(R.layout.main);
    //super.loadUrl("file:///android_asset/www/index.html");
    this.setIntegerProperty("loadUrlTimeoutValue", 60000);
    super.loadUrl("http://10.32.147.28:9080/MYWeb/IndexView.do");
}

I tried commenting and uncommenting many possible combinations above. Here is the configuration: cordova_1.8.0.jar inside the app. cordova1.8.0.js is served by the page above and is not stored locally.

Appreciate any help.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Kiran
  • 5,478
  • 13
  • 56
  • 84
  • have you tried accessing the url via ajax from your html/js file in phonegap?? – dhaval Jun 13 '12 at 17:00
  • No, the same URL loads in the browser though.. One of my requirements is to maintain no local assets and use everything using cache.manifest. Let me try that anyway. – Kiran Jun 13 '12 at 17:17
  • as @fil mentioned below also make sure that `` is set properly (either allow all or your specific ip/domain required). – dhaval Jun 13 '12 at 17:38
  • @Dhaval, is there anyway to set proxy credentials? – Kiran Jun 13 '12 at 17:43
  • try this post to set proxy in emulator - http://stackoverflow.com/questions/28380/proxy-which-requires-authentication-with-android-emulator – dhaval Jun 13 '12 at 17:45
  • also check this post for the chromium error -6, you might find something related to your environment - http://www.sencha.com/forum/showthread.php?187367-Unknown-chromium-error-6 – dhaval Jun 13 '12 at 17:48

1 Answers1

2

Have you set your application whitelist appropriate? You will need to whitelist your server IP.

http://docs.phonegap.com - on the left side, Domain Whitelisting Guide.

fil maj
  • 2,260
  • 16
  • 16
  • Thanks for the tip, I didn't have previously, now I added and tried but it still is the same error. Logcat shows chromium error -400 when I go through local page and ajax fetch, shows chromium error -6 when I directly super.loadUrl("http://10.32.147.28:9080/MYWeb/IndexView.do"); – Kiran Jun 13 '12 at 17:38
  • I just tried creating a new AVD, set the proxy in the emulator and observed that browser asked me for credential for going through proxy. I don't see them set anywhere in the webview. Do I need to have them set some how? or is there a way to set them? – Kiran Jun 13 '12 at 17:42
  • Finally this worked: Launching avd with -http-proxy http://username:password@proxy:port. Though I still needed the whitelist option – Kiran Jun 13 '12 at 18:27