当方向改变时,Phonegap应用程序崩溃在Galaxy Note上

时间:2012-11-26 17:44:32

标签: javascript android cordova

我有几个完整的phonegap应用程序,功能齐全。我已经尝试过我可以访问的整套设备,它不会在我的Galaxy笔记上运行。这是一个全新的设备,我可以运行本机应用程序,但每当我运行任何phonegap应用程序时,我得到一个黑屏,应用程序关闭。没有崩溃,没有警报,没有任何东西。

(我在这里删除了日志,因为它们不相关)

修改

我已经找到了问题,并且在方向发生变化时也能正常运行。一旦我统计我的活动,它就会将方向设置为肖像。

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

因此,我移除了该通道,激活了旋转设备时更改方向的选项。现在,当我启动应用程序时,它会运行,但是当我旋转它时,它会崩溃。我无法弄清楚为什么。我的js代码中有几个警报,但没有一个被触发。有趣的是,当我旋转设备时,cordova默认应用程序也会崩溃。您可以在下面找到这两个日志。

有关如何解决此问题的任何建议吗?

DroidgapExample日志:

11-27 12:41:15.750: D/DroidGap(9129): Paused the application!
11-27 12:41:15.750: D/CordovaWebView(9129): Handle the pause
11-27 12:41:15.750: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:15.750: D/webkit(9129): Firewall not null
11-27 12:41:15.750: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:15.760: D/DroidGap(9129): onDestroy()
11-27 12:41:15.760: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:15.760: D/webkit(9129): Firewall not null
11-27 12:41:15.765: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:15.765: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:15.765: D/webkit(9129): Firewall not null
11-27 12:41:15.765: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:15.775: D/DroidGap(9129): DroidGap.onCreate()
11-27 12:41:15.780: I/webclipboard(9129): clipservice: android.sec.clipboard.ClipboardExManager@4149bc80
11-27 12:41:15.785: D/CordovaWebView(9129): Origin to allow: http://127.0.0.1*
11-27 12:41:15.785: D/CordovaWebView(9129): Origin to allow: .*
11-27 12:41:15.785: I/CordovaLog(9129): Found log level DEBUG
11-27 12:41:15.785: I/CordovaLog(9129): Changing log level to DEBUG(3)
11-27 12:41:15.785: I/CordovaLog(9129): Found preference for useBrowserHistory=false
11-27 12:41:15.785: D/CordovaLog(9129): Found preference for useBrowserHistory=false
11-27 12:41:15.785: I/CordovaLog(9129): Found preference for exit-on-suspend=false
11-27 12:41:15.785: D/CordovaLog(9129): Found preference for exit-on-suspend=false
11-27 12:41:15.785: D/JsMessageQueue(9129): Set native->JS mode to 1
11-27 12:41:15.785: D/DroidGap(9129): DroidGap.init()
11-27 12:41:15.790: D/CordovaWebView(9129): >>> loadUrl(file:///android_asset/www/index.html)
11-27 12:41:15.790: D/PluginManager(9129): init()
11-27 12:41:15.795: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:15.800: D/DroidGap(9129): Resuming the App
11-27 12:41:15.800: D/CordovaLog(9129): JSCallback Error: Request failed with status 0
11-27 12:41:15.800: D/CordovaLog(9129): file:///android_asset/www/cordova-2.1.0.js: Line 3743 : JSCallback Error: Request failed with status 0
11-27 12:41:15.800: I/Web Console(9129): JSCallback Error: Request failed with status 0 at file:///android_asset/www/cordova-2.1.0.js:3743
11-27 12:41:15.800: D/JsMessageQueue(9129): Set native->JS mode to 0
11-27 12:41:15.800: D/WML_SISO(9129): InitPasteboardJni
11-27 12:41:15.805: D/SoftKeyboardDetect(9129): Ignore this event
11-27 12:41:15.810: D/SoftKeyboardDetect(9129): Ignore this event
11-27 12:41:15.810: D/JsMessageQueue(9129): Set native->JS mode to 1
11-27 12:41:15.810: D/DroidGap(9129): onMessage(onPageStarted,about:blank)
11-27 12:41:15.820: W/webcore(9129): java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.WebViewCore$EventHub.removeMessages(WebViewCore.java:2681)
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.WebViewCore$EventHub.access$13000(WebViewCore.java:1365)
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.WebViewCore.removeMessages(WebViewCore.java:2793)
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.WebView.sendOurVisibleRect(WebView.java:4046)
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.ZoomManager.setZoomScale(ZoomManager.java:1024)
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.ZoomManager.access$2100(ZoomManager.java:57)
11-27 12:41:15.820: W/webcore(9129):    at android.webkit.ZoomManager$PostScale.run(ZoomManager.java:1595)
11-27 12:41:15.820: W/webcore(9129):    at android.os.Handler.handleCallback(Handler.java:605)
11-27 12:41:15.820: W/webcore(9129):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-27 12:41:15.820: W/webcore(9129):    at android.os.Looper.loop(Looper.java:137)
11-27 12:41:15.820: W/webcore(9129):    at android.app.ActivityThread.main(ActivityThread.java:4517)
11-27 12:41:15.820: W/webcore(9129):    at java.lang.reflect.Method.invokeNative(Native Method)
11-27 12:41:15.820: W/webcore(9129):    at java.lang.reflect.Method.invoke(Method.java:511)
11-27 12:41:15.820: W/webcore(9129):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:995)
11-27 12:41:15.820: W/webcore(9129):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
11-27 12:41:15.820: W/webcore(9129):    at dalvik.system.NativeStart.main(Native Method)
11-27 12:41:15.820: D/SoftKeyboardDetect(9129): Ignore this event
11-27 12:41:15.825: I/GATE(9129): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
11-27 12:41:15.830: V/(9129): NotificationPresenterImpl::setSettingsValue 0 
11-27 12:41:15.830: V/(9129): NotificationPresenterImpl::setSettingsValue 0 
11-27 12:41:15.835: D/webkit(9129): Firewall not null
11-27 12:41:15.835: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:15.845: D/Cordova(9129): onPageFinished(about:blank)
11-27 12:41:15.845: D/DroidGap(9129): onMessage(onPageFinished,about:blank)
11-27 12:41:15.845: D/DroidGap(9129): onMessage(exit,null)
11-27 12:41:15.900: I/GATE(9129): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
11-27 12:41:16.245: D/DroidGap(9129): onMessage(onPageStarted,file:///android_asset/www/index.html)
11-27 12:41:16.245: D/Cordova(9129): onPageFinished(file:///android_asset/www/index.html)
11-27 12:41:16.245: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:16.245: D/webkit(9129): Firewall not null
11-27 12:41:16.245: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:16.245: D/DroidGap(9129): onMessage(onNativeReady,null)
11-27 12:41:16.245: D/DroidGap(9129): onMessage(onPageFinished,file:///android_asset/www/index.html)
11-27 12:41:16.250: D/DroidGap(9129): Paused the application!
11-27 12:41:16.250: D/CordovaWebView(9129): Handle the pause
11-27 12:41:16.250: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:16.360: D/DroidGap(9129): onMessage(networkconnection,wifi)
11-27 12:41:16.370: D/DroidGap(9129): onMessage(spinner,stop)
11-27 12:41:16.375: D/webkit(9129): Firewall not null
11-27 12:41:16.375: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:16.380: D/CordovaLog(9129): Received Event: deviceready
11-27 12:41:16.380: D/CordovaLog(9129): file:///android_asset/www/js/index.js: Line 47 : Received Event: deviceready
11-27 12:41:16.380: I/Web Console(9129): Received Event: deviceready at file:///android_asset/www/js/index.js:47
11-27 12:41:17.635: D/DroidGap(9129): onDestroy()
11-27 12:41:17.635: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:17.640: D/webkit(9129): Firewall not null
11-27 12:41:17.640: D/CordovaWebView(9129): >>> loadUrlNow()
11-27 12:41:17.640: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:17.640: D/webkit(9129): Firewall not null
11-27 12:41:17.640: D/webkit(9129): euler: isUrlBlocked = false
11-27 12:41:17.650: D/CordovaLog(9129): JSCallback Error: Request failed with status 0
11-27 12:41:17.650: D/CordovaLog(9129): file:///android_asset/www/cordova-2.1.0.js: Line 3743 : JSCallback Error: Request failed with status 0
11-27 12:41:17.650: I/Web Console(9129): JSCallback Error: Request failed with status 0 at file:///android_asset/www/cordova-2.1.0.js:3743
11-27 12:41:17.650: D/JsMessageQueue(9129): Set native->JS mode to 0
11-27 12:41:17.650: D/JsMessageQueue(9129): Set native->JS mode to 1
11-27 12:41:17.660: D/DroidGap(9129): onMessage(onPageStarted,about:blank)
11-27 12:41:17.670: I/GATE(9129): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
11-27 12:41:17.670: D/Cordova(9129): onPageFinished(about:blank)
11-27 12:41:17.670: D/DroidGap(9129): onMessage(onPageFinished,about:blank)
11-27 12:41:17.670: D/DroidGap(9129): onMessage(exit,null)
11-27 12:41:18.255: D/DroidGap(9129): onMessage(spinner,stop)

我的应用日志:

11-27 12:36:41.810: D/DroidGap(10500): Paused the application!
11-27 12:36:41.810: D/CordovaWebView(10500): Handle the pause
11-27 12:36:41.810: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:41.810: D/webkit(10500): Firewall not null
11-27 12:36:41.810: D/webkit(10500): euler: isUrlBlocked = false
11-27 12:36:41.815: D/DroidGap(10500): onDestroy()
11-27 12:36:41.850: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:41.850: D/webkit(10500): Firewall not null
11-27 12:36:41.850: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:41.850: D/webkit(10500): euler: isUrlBlocked = false
11-27 12:36:41.855: D/webkit(10500): Firewall not null
11-27 12:36:41.860: D/webkit(10500): euler: isUrlBlocked = false
11-27 12:36:41.865: D/DroidGap(10500): DroidGap.onCreate()
11-27 12:36:41.875: I/webclipboard(10500): clipservice: android.sec.clipboard.ClipboardExManager@4138e4e0
11-27 12:36:41.880: I/CordovaLog(10500): config.xml missing, reverting to cordova.xml
11-27 12:36:41.880: D/CordovaWebView(10500): Origin to allow: http://127.0.0.1*
11-27 12:36:41.880: I/CordovaLog(10500): Found log level DEBUG
11-27 12:36:41.880: I/CordovaLog(10500): Changing log level to DEBUG(3)
11-27 12:36:41.880: I/CordovaLog(10500): Found preference for classicRender=true
11-27 12:36:41.880: D/CordovaLog(10500): Found preference for classicRender=true
11-27 12:36:41.880: D/JsMessageQueue(10500): Set native->JS mode to 1
11-27 12:36:41.895: D/DroidGap(10500): DroidGap.init()
11-27 12:36:41.900: D/CordovaWebView(10500): >>> loadUrl(file:///android_asset/www/page_A_0.html)
11-27 12:36:41.900: D/PluginManager(10500): init()
11-27 12:36:41.900: I/PluginManager(10500): Using plugins.xml instead of config.xml.  plugins.xml will eventually be deprecated
11-27 12:36:41.905: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:41.910: D/DroidGap(10500): Resuming the App
11-27 12:36:41.915: I/GATE(10500): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
11-27 12:36:41.915: D/CordovaLog(10500): exception firing pause event from native
11-27 12:36:41.915: D/CordovaLog(10500): null: Line 1 : exception firing pause event from native
11-27 12:36:41.915: I/Web Console(10500): exception firing pause event from native at null:1
11-27 12:36:41.915: D/CordovaLog(10500): exception firing destroy event from native
11-27 12:36:41.915: D/CordovaLog(10500): null: Line 1 : exception firing destroy event from native
11-27 12:36:41.915: I/Web Console(10500): exception firing destroy event from native at null:1
11-27 12:36:41.915: W/System.err(10500): java.net.SocketException: Socket closed
11-27 12:36:41.915: W/System.err(10500):    at libcore.io.Posix.accept(Native Method)
11-27 12:36:41.915: W/System.err(10500):    at libcore.io.BlockGuardOs.accept(BlockGuardOs.java:55)
11-27 12:36:41.915: W/System.err(10500):    at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:98)
11-27 12:36:41.915: W/System.err(10500):    at java.net.ServerSocket.implAccept(ServerSocket.java:202)
11-27 12:36:41.915: W/System.err(10500):    at java.net.ServerSocket.accept(ServerSocket.java:127)
11-27 12:36:41.920: W/System.err(10500):    at org.apache.cordova.CallbackServer.run(CallbackServer.java:195)
11-27 12:36:41.920: W/System.err(10500):    at java.lang.Thread.run(Thread.java:856)
11-27 12:36:41.920: D/DroidGap(10500): onMessage(onPageStarted,about:blank)
11-27 12:36:41.920: D/WML_SISO(10500): InitPasteboardJni
11-27 12:36:41.920: D/SoftKeyboardDetect(10500): Ignore this event
11-27 12:36:41.920: V/(10500): NotificationPresenterImpl::setSettingsValue 0 
11-27 12:36:41.920: V/(10500): NotificationPresenterImpl::setSettingsValue 0 
11-27 12:36:41.925: D/webkit(10500): Firewall not null
11-27 12:36:41.925: D/webkit(10500): euler: isUrlBlocked = false
11-27 12:36:41.930: D/SoftKeyboardDetect(10500): Ignore this event
11-27 12:36:41.935: D/Cordova(10500): onPageFinished(about:blank)
11-27 12:36:41.935: D/DroidGap(10500): onMessage(onPageFinished,about:blank)
11-27 12:36:41.935: D/DroidGap(10500): onMessage(exit,null)
11-27 12:36:41.970: D/chromium(10500): Unknown chromium error: -6
11-27 12:36:42.315: D/DroidGap(10500): onMessage(onPageStarted,file:///android_asset/www/page_A_0.html)
11-27 12:36:42.315: D/SoftKeyboardDetect(10500): Ignore this event
11-27 12:36:42.360: D/DroidGap(10500): Paused the application!
11-27 12:36:42.360: D/CordovaWebView(10500): Handle the pause
11-27 12:36:42.360: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:42.555: W/IInputConnectionWrapper(10500): showStatusIcon on inactive InputConnection
11-27 12:36:43.465: D/DroidGap(10500): onDestroy()
11-27 12:36:43.465: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:43.465: D/CordovaWebView(10500): >>> loadUrlNow()
11-27 12:36:43.480: E/WindowManager(10500): Activity co.uk.precedent.tesco.CordovaTuxedoActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41449660 that was originally added here
11-27 12:36:43.480: E/WindowManager(10500): android.view.WindowLeaked: Activity co.uk.precedent.tesco.CordovaTuxedoActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41449660 that was originally added here
11-27 12:36:43.480: E/WindowManager(10500):     at android.view.ViewRootImpl.<init>(ViewRootImpl.java:414)
11-27 12:36:43.480: E/WindowManager(10500):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:282)
11-27 12:36:43.480: E/WindowManager(10500):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:218)
11-27 12:36:43.480: E/WindowManager(10500):     at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:143)
11-27 12:36:43.480: E/WindowManager(10500):     at android.view.Window$LocalWindowManager.addView(Window.java:548)
11-27 12:36:43.480: E/WindowManager(10500):     at android.app.Dialog.show(Dialog.java:337)
11-27 12:36:43.480: E/WindowManager(10500):     at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
11-27 12:36:43.480: E/WindowManager(10500):     at org.apache.cordova.CordovaChromeClient.onJsAlert(CordovaChromeClient.java:119)
11-27 12:36:43.480: E/WindowManager(10500):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:628)
11-27 12:36:43.480: E/WindowManager(10500):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 12:36:43.480: E/WindowManager(10500):     at android.os.Looper.loop(Looper.java:137)
11-27 12:36:43.480: E/WindowManager(10500):     at android.app.ActivityThread.main(ActivityThread.java:4517)
11-27 12:36:43.480: E/WindowManager(10500):     at java.lang.reflect.Method.invokeNative(Native Method)
11-27 12:36:43.480: E/WindowManager(10500):     at java.lang.reflect.Method.invoke(Method.java:511)
11-27 12:36:43.480: E/WindowManager(10500):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:995)
11-27 12:36:43.480: E/WindowManager(10500):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
11-27 12:36:43.480: E/WindowManager(10500):     at dalvik.system.NativeStart.main(Native Method)

2 个答案:

答案 0 :(得分:1)

首先,它不是设备兼容性问题 - 我在这里有一个Galaxy Note,可以毫无问题地运行PhoneGap应用程序。

您是否尝试过运行默认的Cordova模板应用以排除更复杂的应用特定问题?

防火墙消息表明您的应用正在尝试在启动期间通过网络加载某些内容 - 您的问题并未提供有关可能内容的任何信息,但不应过于难以追踪。

答案 1 :(得分:0)

我刚才用this answer对它进行了排序。

在每个活动中将screenSize属性添加到我的配置更改属性解决了问题。请记住,它是在API级别13中添加的。

android:configChanges="orientation|screenSize|keyboardHidden"