A network error occurred. (file:///android_asset/www/index.html?#)

  • 5
  • Question
  • Updated 8 years ago
Merged

This conversation has been merged. Please reference the main conversation: Phonegap Build: viewebclient timeout error on android device

I developed a WP7 app using HTML, JS, and CSS following PhoneGap guidelines which works great on WP7 then I uploaded all the HTML, JS, CSS, PNG files in the "www" folders to PhoneGap build (https://build.phonegap.com/apps/53447). Build seems to have successed than I downloaded the APK file and deployed it to Android device emulator. The main page starts find but when I interact with app I get:

Application Error

A network error occurred. (file:///android_asset/www/index.html?#)

Can someone help please.

Thanks,
Mohamed
Photo of Mohamed El-Ghazali

Mohamed El-Ghazali

  • 3 Posts
  • 0 Reply Likes
  • sad

Posted 9 years ago

  • 5
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Hey Mohamed,

I think the first place we should start to diagnose the issue is to remove the phonegap.js files from your project (phonegap-1.2.0.js).

Also in your index.html please change


<script type="text/javascript" src="phonegap-1.2.0.js"></script>


to


<script type="text/javascript" src="phonegap.js"></script>


Hardeep Shoker
Photo of moni

moni

  • 0 Posts
  • 0 Reply Likes
Hardeep..I am new to phone gap. Have the same issue.removal of phonegap-2.0.0 solved the issue. But someone has suggested super.setIntegerProperty("loadUrlTimeoutValue", 60000). That did not work for me. But for going forward if I have to use the js in the phonegap.js files, I will have the same issue again? What is the alternative?
Photo of Alexander Ustimenko

Alexander Ustimenko

  • 3 Posts
  • 0 Reply Likes
Hardeep, dont' you plan to add some android specific config param, that will help to set those "loadUrlTimeoutValue" param?

I know, that I always can build my own android app with phonegap, but I want it to be in one place -- in phonegap build. If it will not be there -- then android in phonegap build becomes not so useful.

Another option is to make code with timeouts more robust. But anyway this part becomes a very big risk and it's better to not use build for android -- only for other platforms.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Hey Alex, I will discuss this with the team.

Hardeep Shoker
Photo of Alexander Ustimenko

Alexander Ustimenko

  • 3 Posts
  • 0 Reply Likes
Hardeep, tnx.

May be as a dirty workaround will be good to add as default timeout 60000, as all suggests in google. But I think problem here is more deep as you can see from code, that throws that exception.

ps: I like to be named Alexander -- in Russia we have two names with similar root: Alexander & Alexey, but they are just different names.
Photo of Eyal Peleg

Eyal Peleg

  • 149 Posts
  • 2 Reply Likes
Hardeep,
8 monts later, this is still an issue :(
Was thid discussed with the team?
Is there a PGB workaround for this problem ?
Photo of Mohamed El-Ghazali

Mohamed El-Ghazali

  • 3 Posts
  • 0 Reply Likes
Thank you Hardeep. That solved the issue.

-Mohamed
Photo of Jeff

Jeff

  • 23 Posts
  • 0 Reply Likes
Hardeep - I second Alexander's recommendation for a config.xml parameter controlling loadUrlTimeoutValue. This seems like a very common issue:

http://stackoverflow.com/questions/65...

http://www.google.com/search?gcx=c&so...

As PG Build aims to standardize any SDK-level configuration, giving users the ability to control this via config.xml seems fairly essential.
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
Thanks jeff,

I will note this down.

Hardeep Shoker
Photo of lawgurl

lawgurl

  • 361 Posts
  • 14 Reply Likes
I am having a similar issue...

The connection to the server was unsuccessful. (file:///android_asset/www/index.html)

Can someone explain the nature of this Application, what is triggering it and how to prevent it from occurring?

I've been using jQuery for the majority of my apps, but this is the first time I've come up with this issue or any major issue that's preventing my app from displaying fully.

Thank You!
Dax
Photo of Jeff

Jeff

  • 23 Posts
  • 0 Reply Likes
Dax - the issue is explained in detail at the links I posted above.

Hardeep - this issue is common enough that the jQuery Mobile team has added it to their official documentation, on the "PhoneGap" page (down in the "Still having issues?" section:

http://jquerymobile.com/demos/1.0/doc...
Photo of lawgurl

lawgurl

  • 361 Posts
  • 14 Reply Likes
So basically this is an issue that just sprung up because all of the builds minus one that I have in my build archive utilizes jQ. Last night/ early this morning is the first time that I've experienced this. Or is this something that comes about with the right file combo?

Hmmmmm. Thank you for the links Jeff!

I went to the listed links, however, even though it appears as thougto the same h we are arriving to the same conclusion with jQ and PG being our common threads, different individuals are resolving their issue differently and NOT in a uniform and set way.

For instance, some (the majority) have a phonegap-xxx.js file included, I don't so my resolution could very well be different from someone who does as it appears as those who are using that file have their own varying resolutions to the issue....

Hmmmmm! This is strange...

But thanks for keeping me in the loop.

Dax
Photo of rpalmer1968

rpalmer1968

  • 11 Posts
  • 0 Reply Likes
I'm getting the same Network error as the original poster when I try to run my app built with PhoneGap:Build on the Android 4.x Emulator.

It works fine under Android 2.x and 3.x but 4.x gives the network error.

I'm not using jQuery at all, just a simple http request for a page.

var req = new XMLHttpRequest();
req.open('GET', url, true);
req.send(null);

I'm not using PhoneGap just PhoneGap:Build, so can I add something to my code to fix this?

App number is 33926.

Thanks
Photo of Alexander Ustimenko

Alexander Ustimenko

  • 3 Posts
  • 0 Reply Likes
No. One solution is not to use PhoneGap:Build and add code like this manually:

package com.blbla.bla; // It's your package`s name

import android.os.Bundle;

import com.phonegap.DroidGap;

public class App extends DroidGap { // Name your App as you want

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
///super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Photo of Hardeep Shoker

Hardeep Shoker

  • 1941 Posts
  • 89 Reply Likes
rpalmer,

Are you performing a debug build? We have a timeout issue on the 4.x emulators when debug is enabled. The interm solution for build users is to disable the debug feature when using the 4.x emulator.

Hardeep Shoker
Photo of piyush.goel

piyush.goel

  • 1 Post
  • 0 Reply Likes
I was getting the same error. The error in my case was that I needed three slashes ('///') after 'file:'. This may be some of yours' problem so thought will share.

Piyush
Photo of Narayana

Narayana

  • 1 Post
  • 0 Reply Likes
Hi,
Please check the files name given in activity file and html file in www.
ex: Activity File:-> super.loadUrl("file:///android_asset/www/index.html");
www folder:-> Index.html
Here the file name mis-matches.So,check with the file names alo.
Photo of yosauron.desarrollo

yosauron.desarrollo

  • 44 Posts
  • 7 Reply Likes
I have the same horrible error!
I use PhoneGap Build, and I don't know how do I solve this using only Phonegap Build,

Any help/solution?

Thank you
Photo of Mja

Mja

  • 6 Posts
  • 0 Reply Likes
i have the same problem, please, can help me anyone?? thanks