我正在尝试学习Phonegap,并使用互联网上的教程制作了第一个应用程序但我的应用程序崩溃显示应用程序错误,因为存在网络错误(文件://android_asset/www/index.html)。我尝试了很多东西,但对我来说没有任何作用。请任何人帮忙。提前致谢。 这是我的日志猫输出:
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
这是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>
这是我的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");
}
}
我正在尝试在genymotion上运行应用程序。
答案 0 :(得分:1)
Mainfest文件已更改为:
<?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>
然后将主要活动更改为:
super.setIntegerProperty(“loadUrlTimeoutValue”,60000);
答案 1 :(得分:0)
试试这个:
super.setIntegerProperty("loadUrlTimeoutValue", 70000);
super.loadUrl("file:///android_asset/www/index.html");