Reputation: 111
I am trying to learn Phonegap and made a first app using the tutorials on internet but my application is crashing showing application error as There was a network error(file://android_asset/www/index.html). I have tried many things but nothing worked for me yet. Please anyone help. Thanks in advance. This is my log cat output:
07-12 05:33:39.109: D/DroidGap(1395): Resuming the App
07-12 05:33:39.113: D/chromium(1395): Unknown chromium error: -6
07-12 05:33:39.653: D/DroidGap(1395): onMessage(onPageStarted,file://android_asset/www/index.html)
07-12 05:33:39.733: D/Cordova(1395): CordovaWebViewClient.onReceivedError: Error code=-1 Description=There was a network error. URL=file://android_asset/www/index.html
07-12 05:33:39.773: D/DroidGap(1395): onMessage(onReceivedError,{"errorCode":-1,"url":"file:\/\/android_asset\/www\/index.html","description":"There was a network error."})
07-12 05:33:40.121: D/DroidGap(1395): onMessage(onPageStarted,file://android_asset/www/index.html)
07-12 05:33:40.273: D/Cordova(1395): onPageFinished(file://android_asset/www/index.html)
07-12 05:33:40.277: D/DroidGap(1395): onMessage(onNativeReady,null)
07-12 05:33:40.305: D/DroidGap(1395): onMessage(onPageFinished,file://android_asset/www/index.html)
07-12 05:33:40.309: I/Choreographer(1395): Skipped 51 frames! The application may be doing too much work on its main thread.
07-12 05:33:40.365: D/SoftKeyboardDetect(1395): Ignore this event
07-12 05:33:41.105: W/EGL_emulation(1395): eglSurfaceAttrib not implemented
07-12 05:33:41.417: W/EGL_emulation(1395): eglSurfaceAttrib not implemented
07-12 05:33:41.421: I/Choreographer(1395): Skipped 62 frames! The application may be doing too much work on its main thread.
07-12 05:33:41.541: D/OpenGLRenderer(1395): TextureCache::get: create texture(0xb81cadf0): name, size, mSize = 21, 1048576, 1072788
07-12 05:33:41.985: D/Cordova(1395): onPageFinished(file://android_asset/www/index.html)
07-12 05:33:42.125: D/DroidGap(1395): onMessage(onNativeReady,null)
07-12 05:33:42.165: D/DroidGap(1395): onMessage(onPageFinished,file://android_asset/www/index.html)
07-12 05:33:42.265: D/SoftKeyboardDetect(1395): Ignore this event
07-12 05:44:42.961: D/dalvikvm(1395): GC_CONCURRENT freed 164K, 5% free 6470K/6791K, paused 23ms+3ms, total 41ms
07-12 05:44:42.993: D/webviewglue(1395): nativeDestroy view: 0xb82b8310
and this is index.html
<!DOCTYPE HTML>
<HTML>
<head>
<title>AjpdSoft PhoneGap</title>
<script type="text/JavaScript" CharSet="UTF-8" SRC="CORDOVA-2.2.0.JS"></script>
</head>
<body>
<h1>Hello world PhoneGap</h1>
<p>Example of application Android with PhoneGap and Eclipse</p>
< /body>
</HTML>
This is my MainActivity.java
import android.os.Bundle;
//import org.Apache.cordova.*;
import org.apache.cordova.DroidGap;
public class MainActivity extends DroidGap
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file://android_asset/www/index.html");
}
}
I am trying to run the app on genymotion.
Upvotes: 0
Views: 507
Reputation: 111
Mainfest file changed to :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.phonegaphello"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.phonegaphello.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and then change in Main activity as:
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
Upvotes: 1
Reputation: 14315
try this:
super.setIntegerProperty("loadUrlTimeoutValue", 70000);
super.loadUrl("file:///android_asset/www/index.html");
Upvotes: 0