简体   繁体   中英

Phonegap App crashing on Galaxy Note when orientation changes

I have a couple of complete phonegap apps, fully functional. I've tried in the whole set of devices I have access to, and it doesn't run on my galaxy note. It's a brand new device, I can run native apps, but whenever I run any phonegap app i get a black screen and the app closes. No crash, no alert, no nothing.

(I remove the logs here because they were not relevant)

EDIT

I've tracked down the issue and it works when the orientation changes. As soon as I stat my activity it sets the orientation to portrait.

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

So I removed that lane, activated the option to change the orientation when I rotate the device. Now when I start the app it runs, but when I rotate it, it crashes. I can't figure out why. I have several alerts in my js code and none of them is fired. The interesting thing is the cordova default app also crashes when I rotate the device. Below you can find both logs.

Any suggestions on how to fix this?

DroidgapExample log:

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)

My App log:

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)

Firstly, it isn't a device compatibility issue - I have a Galaxy Note here that runs PhoneGap apps without any problems.

Have you tried running the default Cordova template app to rule out more complex app-specific issues?

The firewall messages suggest that your app is trying to load something over the network during startup - your question doesn't give any information on what that might be, but it shouldn't be too hard to track down.

I've sorted this a while ago, with this answer .

adding the screenSize property to my config changes attribute in every activity solved the problem. Bear in mind it was added in API level 13.

android:configChanges="orientation|screenSize|keyboardHidden"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM