简体   繁体   English

如何避免Android上的Phonegap app空白屏幕?

[英]How to avoid Phonegap app blank screen only on Android?

I'm deploying a web app with phonegap to the plataforms: iOS and Android. 我正在部署一个带有phonegap的网络应用程序:iOS和Android。

I can deploy both, but when the app starts, on the android emulator (also, with any physic device that i've used it to test the application), it stays with a white/blank canvas. 我可以部署两者,但是当应用程序启动时,在Android模拟器上 (也可以使用我用它来测试应用程序的任何物理设备),它会保留一个白色/空白画布。 Forever. 永远。

Initially, i thought it was javascript related, although i don't think it makes sense, since i don't have the same problem with iOS (but i know, it could be browser related). 最初,我认为这是javascript相关的,虽然我不认为这是有道理的,因为我没有与iOS相同的问题(但我知道,它可能是浏览器相关)。

I've research this problem through the internet, but any possible solution that probably would make sense, didn't work for me. 我通过互联网研究这个问题,但任何可能有意义的解决方案对我来说都不适用。

Solutions i tried: 解决方案我试过:

PhoneGap Build iOS app has blank white screen after splash screen 启动画面后,PhoneGap Build iOS应用程序有空白屏幕

The Phonegap Version i'm using is: v3.3.0 我正在使用的Phonegap版本是:v3.3.0

Also, i'm using a Javascript framework: Dojo, v1.9 此外,我正在使用Javascript框架:Dojo,v1.9

My tl;dr answer is...debug that thing with Weinre: 我的回答是......用Weinre调试那个东西:

http://people.apache.org/~pmuellr/weinre/docs/latest/ http://people.apache.org/~pmuellr/weinre/docs/latest/

Weinre is very similar to the Chrome/Safari inspector, only for remote browsers (such as the native WebView!). Weinre与Chrome / Safari检查器非常相似,仅适用于远程浏览器(例如本机WebView!)。 Pretty sweet, eh? 很甜蜜,嗯? It involves a little setup but has been well worth it for me. 它涉及一些设置,但对我来说非常值得。 Interactively test your assumptions and see your console.log statements print out in a far superior fashion than with logcat (in the android case). 交互式测试您的假设,并看到您的console.log语句打印出来的方式远远超过logcat(在android案例中)。


Some reflections on the matter: 对此事的一些反思:

Developing my app over the last couple months, I've encountered the blank screen tons of times. 在过去的几个月中开发我的应用程序,我遇到了很多次的空白屏幕。 It is never the same issue twice, for me it always something I have broken during development. 它永远不会是两次相同的问题,对我而言,它始终是我在开发过程中遇到的问题。

For example, not adding a Cordova plugin via the command line but trying to reference the plugin in my app's javascript logic. 例如,不是通过命令行添加Cordova插件,而是尝试在我的应用程序的javascript逻辑中引用插件。

Another example is not having proper Cross Origin stuff setup on the server and the initial ajax call that worked fine on desktop/localhost suddenly doesn't work once deployed to the device and it just craps out (giving the white screen). 另一个例子是没有在服务器上设置正确的Cross Origin东西,并且在桌面/ localhost上工作正常的初始ajax调用突然在部署到设备后不起作用并且它只是缩小(给出白色屏幕)。

Another example from the other day was trying to see if I could get away with using Sencha on Android as old as 2.3, which in my case, you guessed it gave me a white screen. 另一天的另一个例子是试图看看我是否可以在Android上使用Sencha而不是2.3,在我的情况下,你猜对了它给了我一个白色的屏幕。 Maybe Dojo has a similar issue? 也许Dojo有类似的问题?


As requested, the settings in my current config.xml that works fine on both iOS and Android 根据要求,我当前的config.xml中的设置在iOS和Android上均可正常运行

<preference name="permissions" value="none" />
<preference name="orientation" value="portrait" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="auto" />

Hope this helps. 希望这可以帮助。

Phonegap 6.3 scaffholding ( phonegap create ) is wrong: density should be replaced by qualifier in config.xml . Phonegap 6.3 scaffholding( phonegap create )是错误的: 密度应该用config.xml限定符替换。 See https://medium.com/@jlchereau/how-to-get-splash-screens-to-show-in-android-apps-generated-by-phonegap-build-c0210f2783ff . 请参阅https://medium.com/@jlchereau/how-to-get-splash-screens-to-show-in-android-apps-generated-by-phonegap-build-c0210f2783ff

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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