【问题标题】:Application error on AVD with Phonegap hello world app使用 Phonegap hello world 应用程序在 AVD 上出现应用程序错误
【发布时间】:2014-07-12 05:48:40
【问题描述】:

我正在尝试学习 Phonegap 并使用互联网上的教程制作了第一个应用程序,但我的应用程序崩溃并显示应用程序错误,因为存在网络错误(file://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 上运行该应用。

【问题讨论】:

  • 你好,请给我看看你的 helloword.java 文件
  • 请检查我已经编辑了问题并添加了 MainActivity.java

标签: android eclipse cordova


【解决方案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);

【讨论】:

    【解决方案2】:

    试试这个:

     super.setIntegerProperty("loadUrlTimeoutValue", 70000);
     super.loadUrl("file:///android_asset/www/index.html");
    

    【讨论】:

    • 我正在尝试:)...你能告诉我在“loadUrlTimeoutValue”中写什么吗?我可以这样写 super.setIntegerProperty(3000, 7000);
    • 不,你不能写,你只需要复制粘贴
    • 这并没有解决我的问题...但是这次没有 chrome 错误..但我仍然收到此错误 D/Cordova(1481): onPageFinished(file://android_asset/ www/index.html)
    • 请更改此行.. 使您的科尔多瓦文件名称相同
    • 没有哥们...还是一样
    猜你喜欢
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    相关资源
    最近更新 更多