您好,我正在使用 PhoneGap Android 并发布了一个应用程序,该应用程序可以在 Android 2.3.3 下在虚拟设备和实际设备中运行。
但是,当在 Android 4.1 上同时在虚拟设备和实际设备上运行时,该应用程序甚至不会超过应用程序的第一页。
我对可能出现的问题感到茫然,因为我已将每段代码都放在了 try 块中,但它们都没有被触发,并且该应用程序在旧版本中运行良好。
这是我在 Android 4.1 下的 logcat
10-14 22:48:53.502: I/CordovaLog(871): Changing log level to DEBUG(3)
10-14 22:48:53.502: I/CordovaLog(871): Found preference for useBrowserHistory=false
10-14 22:48:53.512: D/CordovaLog(871): Found preference for useBrowserHistory=false
10-14 22:48:53.562: D/JsMessageQueue(871): Set native->JS mode to 1
10-14 22:48:53.694: D/DroidGap(871): DroidGap.init()
10-14 22:48:53.822: D/CordovaWebView(871): DroidGap.loadUrl(file:///android_asset/www/splash.html, 10000)
10-14 22:48:53.822: D/DroidGap(871): onMessage(splashscreen,show)
10-14 22:48:54.202: D/dalvikvm(871): GC_FOR_ALLOC freed 87K, 3% free 8080K/8259K, paused 335ms, total 339ms
10-14 22:48:54.312: I/dalvikvm-heap(871): Grow heap (frag case) to 9.111MB for 1228816-byte allocation
10-14 22:48:54.522: D/dalvikvm(871): GC_FOR_ALLOC freed 1K, 3% free 9278K/9479K, paused 201ms, total 201ms
10-14 22:48:55.032: D/dalvikvm(871): GC_CONCURRENT freed 4K, 3% free 9283K/9479K, paused 102ms+77ms, total 440ms
10-14 22:48:56.101: D/CordovaWebView(871): >>> loadUrl(file:///android_asset/www/splash.html)
10-14 22:48:56.101: D/PluginManager(871): init()
10-14 22:48:56.141: D/CordovaWebView(871): >>> loadUrlNow()
10-14 22:48:56.141: D/DroidGap(871): Resuming the App
10-14 22:48:56.192: I/Choreographer(871): Skipped 33 frames! The application may be doing too much work on its main thread.
10-14 22:48:56.532: D/SoftKeyboardDetect(871): Ignore this event
10-14 22:48:56.802: I/Choreographer(871): Skipped 75 frames! The application may be doing too much work on its main thread.
10-14 22:48:56.973: D/gralloc_goldfish(871): Emulator without GPU emulation detected.
10-14 22:48:57.764: D/SoftKeyboardDetect(871): Ignore this event
10-14 22:48:59.602: D/DroidGap(871): onMessage(onPageStarted,file:///android_asset/www/splash.html)
10-14 22:49:06.772: D/SoftKeyboardDetect(871): Ignore this event
10-14 22:49:16.172: E/CordovaWebView(871): CordovaWebView: TIMEOUT ERROR!
10-14 22:49:16.172: D/Cordova(871): CordovaWebViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///android_asset/www/splash.html
10-14 22:49:16.232: D/DroidGap(871): onMessage(onReceivedError,{"errorCode":-6,"url":"file:\/\/\/android_asset\/www\/splash.html","description":"The connection to the server was unsuccessful."})
10-14 22:49:16.764: I/Choreographer(871): Skipped 131 frames! The application may be doing too much work on its main thread.
10-14 22:49:16.764: D/SoftKeyboardDetect(871): Ignore this event
10-14 22:49:17.321: D/Cordova(871): onPageFinished(file:///android_asset/www/splash.html)
10-14 22:49:17.332: D/CordovaWebView(871): >>> loadUrlNow()
10-14 22:49:17.364: D/DroidGap(871): onMessage(onNativeReady,null)
10-14 22:49:17.364: D/DroidGap(871): onMessage(onPageFinished,file:///android_asset/www/splash.html)
10-14 22:49:17.386: I/Choreographer(871): Skipped 112 frames! The application may be doing too much work on its main thread.
10-14 22:49:49.262: D/DroidGap(871): Paused the application!
10-14 22:49:50.032: W/IInputConnectionWrapper(871): showStatusIcon on inactive InputConnection
10-14 22:49:51.446: D/DroidGap(871): onDestroy()
10-14 22:49:51.446: D/CordovaWebView(871): >>> loadUrlNow()
10-14 22:49:51.472: D/CordovaWebView(871): >>> loadUrlNow()
10-14 22:49:51.642: D/DroidGap(871): onMessage(onPageStarted,about:blank)
10-14 22:49:51.682: W/System.err(871): java.net.SocketException: Socket closed
10-14 22:49:51.682: W/System.err(871): at libcore.io.Posix.accept(Native Method)
10-14 22:49:51.702: W/System.err(871): at libcore.io.BlockGuardOs.accept(BlockGuardOs.java:55)
10-14 22:49:51.702: W/System.err(871): at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:98)
10-14 22:49:51.702: W/System.err(871): at java.net.ServerSocket.implAccept(ServerSocket.java:202)
10-14 22:49:51.702: W/System.err(871): at java.net.ServerSocket.accept(ServerSocket.java:127)
10-14 22:49:51.702: W/System.err(871): at org.apache.cordova.CallbackServer.run(CallbackServer.java:195)
10-14 22:49:51.702: W/System.err(871): at java.lang.Thread.run(Thread.java:856)
10-14 22:49:52.302: D/Cordova(871): onPageFinished(about:blank)
10-14 22:49:52.312: D/DroidGap(871): onMessage(onPageFinished,about:blank)
10-14 22:49:52.312: D/DroidGap(871): onMessage(exit,null)
任何帮助将非常感激。
谢谢你。
编辑:
我正在使用 PhoneGap 版本:cordova-2.1.0.js
通过更多阅读,我还将这一行添加到我的 MainActivity.java
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
并且还将 ADB 连接超时从 5000 更改为 10000
这是我的清单文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.game.demo"
android:versionCode="2"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>