This issue is pretty perplexing and my eyes can only take so much of looking at a Kindle device before burning with rage, so I'd like your help, generous Internet folk!
I'm working on an app that is built on Sencha Touch 2.3.1 and Cordova 3.5.1. I have this app working on really any other Android device I've tested on except for the newest Fire HD devices from Amazon, and in my case, a Fire HD 6.
When I build the APK, sign it, zipalign it, etc. and then post it online for download to the device, I'm seeing an issue of a grey screen ONLY WHEN STARTING IN PORTRAIT. Here is the screenshot:
When I start in Landscape mode, I get this screenshot:
The crazier part is that when I start the app in portrait (grey screen), rotate to landscape (no change), and then rotate back to portrait, close the app, and reopen it, the correct portrait screen is shown, here:
In contrast to the signed APK, when I build the app for testing in Eclipse and deploy to the device, the app works as expected. The only difference I can discern between the Eclipse version and the signed APK is the way that the Cordova jar file is included in the project. Here is the log file from the Fire HD 6 when I build from Eclipse:
10-15 13:36:00.715: I/Activity(16158): No ActvityExender defined. Proceed with default activity behavior.
10-15 13:36:00.719: I/CordovaLog(16158): Changing log level to DEBUG(3)
10-15 13:36:00.722: D/Whitelist(16158): Unlimited access to network resources
10-15 13:36:00.723: D/CordovaActivity(16158): CordovaActivity.onCreate()
10-15 13:36:00.726: D/CordovaActivity(16158): Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml
10-15 13:36:00.726: D/CordovaActivity(16158): Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml
10-15 13:36:00.750: W/BindingManager(16158): Cannot setInForeground() - never saw a connection for the pid: 16158
10-15 13:36:00.771: D/CordovaWebView(16158): CordovaWebView is running on device made by: Amazon
10-15 13:36:00.775: D/JsMessageQueue(16158): Set native->JS mode to 2
10-15 13:36:00.776: D/CordovaActivity(16158): CordovaActivity.init()
10-15 13:36:00.860: D/CordovaWebView(16158): >>> loadUrl(file:///android_asset/www/index.html)
10-15 13:36:00.860: D/PluginManager(16158): init()
10-15 13:36:00.874: D/CordovaWebView(16158): >>> loadUrlNow()
10-15 13:36:00.875: W/BindingManager(16158): Cannot setInForeground() - never saw a connection for the pid: 0
10-15 13:36:00.875: W/BindingManager(16158): Cannot setInForeground() - never saw a connection for the pid: 16158
10-15 13:36:00.877: I/CordovaLog(16158): Changing log level to DEBUG(3)
10-15 13:36:00.881: D/Whitelist(16158): Unlimited access to network resources
10-15 13:36:00.881: D/CordovaActivity(16158): Resuming the App
10-15 13:36:00.881: D/CordovaActivity(16158): CB-3064: The errorUrl is null
10-15 13:36:00.989: D/SoftKeyboardDetect(16158): Ignore this event
10-15 13:36:01.037: D/SoftKeyboardDetect(16158): Ignore this event
10-15 13:36:01.059: D/SoftKeyboardDetect(16158): Ignore this event
10-15 13:36:01.067: D/CordovaWebViewClient(16158): onPageStarted(file:///android_asset/www/index.html)
10-15 13:36:01.067: D/CordovaActivity(16158): onMessage(onPageStarted,file:///android_asset/www/index.html)
10-15 13:36:01.390: D/SoftKeyboardDetect(16158): Ignore this event
10-15 13:36:02.039: D/CordovaActivity(16158): onMessage(spinner,stop)
10-15 13:36:02.043: D/CordovaNetworkManager(16158): Connection Type: wifi
10-15 13:36:02.068: E/chromium(16158): [ERROR:gl_context.cc(53)] Not implemented reached in virtual void gfx::GLContext::SetUnbindFboOnMakeCurrent()
10-15 13:36:02.068: I/chromium(16158): [INFO:async_pixel_transfer_manager_android.cc(60)] Async pixel transfers not supported
10-15 13:36:02.083: D/CordovaNetworkManager(16158): Connection Type: wifi
10-15 13:36:02.083: D/CordovaActivity(16158): onMessage(networkconnection,wifi)
10-15 13:36:02.100: D/CordovaWebViewClient(16158): onPageFinished(file:///android_asset/www/index.html)
10-15 13:36:02.100: D/CordovaActivity(16158): onMessage(onPageFinished,file:///android_asset/www/index.html)
10-15 13:36:02.324: D/CordovaLog(16158): file:///android_asset/www/app.js: Line 1 : a launch right here: file:///android_asset/www/index.html
10-15 13:36:02.324: I/chromium(16158): [INFO:CONSOLE(1)] "a launch right here: file:///android_asset/www/index.html", source: file:///android_asset/www/app.js (1)
10-15 13:36:02.345: D/CordovaLog(16158): file:///android_asset/www/app.js: Line 1 : index: gotFS
10-15 13:36:02.345: I/chromium(16158): [INFO:CONSOLE(1)] "index: gotFS", source: file:///android_asset/www/app.js (1)
10-15 13:36:02.347: D/CordovaLog(16158): file:///android_asset/www/app.js: Line 1 : here is the root: cdvfile://localhost/persistent/
10-15 13:36:02.347: I/chromium(16158): [INFO:CONSOLE(1)] "here is the root: cdvfile://localhost/persistent/", source: file:///android_asset/www/app.js (1)
10-15 13:36:04.256: I/App(16158): WARNING: Back Button Default Behavior will be overridden. The backbutton event will be fired!
10-15 13:36:04.293: W/System.err(16158): org.apache.cordova.file.FileExistsException: create/exclusive fails
10-15 13:36:04.294: W/System.err(16158): at org.apache.cordova.file.LocalFilesystem.getFileForLocalURL(LocalFilesystem.java:176)
10-15 13:36:04.294: W/System.err(16158): at org.apache.cordova.file.FileUtils.getFile(FileUtils.java:698)
10-15 13:36:04.294: W/System.err(16158): at org.apache.cordova.file.FileUtils.access$5(FileUtils.java:691)
10-15 13:36:04.294: W/System.err(16158): at org.apache.cordova.file.FileUtils$16.run(FileUtils.java:349)
10-15 13:36:04.294: W/System.err(16158): at org.apache.cordova.file.FileUtils$23.run(FileUtils.java:477)
10-15 13:36:04.294: W/System.err(16158): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-15 13:36:04.294: W/System.err(16158): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-15 13:36:04.294: W/System.err(16158): at java.lang.Thread.run(Thread.java:841)
10-15 13:36:04.296: W/System.err(16158): org.apache.cordova.file.FileExistsException: create/exclusive fails
10-15 13:36:04.296: W/System.err(16158): at org.apache.cordova.file.LocalFilesystem.getFileForLocalURL(LocalFilesystem.java:176)
10-15 13:36:04.296: W/System.err(16158): at org.apache.cordova.file.FileUtils.getFile(FileUtils.java:698)
10-15 13:36:04.297: W/System.err(16158): at org.apache.cordova.file.FileUtils.access$5(FileUtils.java:691)
10-15 13:36:04.297: W/System.err(16158): at org.apache.cordova.file.FileUtils$16.run(FileUtils.java:349)
10-15 13:36:04.297: W/System.err(16158): at org.apache.cordova.file.FileUtils$23.run(FileUtils.java:477)
10-15 13:36:04.297: W/System.err(16158): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
10-15 13:36:04.297: W/System.err(16158): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
10-15 13:36:04.297: W/System.err(16158): at java.lang.Thread.run(Thread.java:841)
10-15 13:36:04.719: D/CordovaLog(16158): file:///android_asset/www/app.js: Line 1 : 12
10-15 13:36:04.719: I/chromium(16158): [INFO:CONSOLE(1)] "12", source: file:///android_asset/www/app.js (1)
10-15 13:36:04.720: D/CordovaLog(16158): file:///android_asset/www/app.js: Line 1 : 12
10-15 13:36:04.720: I/chromium(16158): [INFO:CONSOLE(1)] "12", source: file:///android_asset/www/app.js (1)
10-15 13:36:04.743: D/TEST(16158): cdvfile://localhost/persistent/com.------.------/data/downloadQueue.json: 12
10-15 13:36:04.863: D/CordovaLog(16158): file:///android_asset/www/plugins/com.smartmobilesoftware.inappbilling/www/inappbilling.js: Line 6 : InAppBilling[js]: setup ok
10-15 13:36:04.863: I/chromium(16158): [INFO:CONSOLE(6)] "InAppBilling[js]: setup ok", source: file:///android_asset/www/plugins/com.smartmobilesoftware.inappbilling/www/inappbilling.js (6)
10-15 13:36:05.118: D/CordovaActivity(16158): onMessage(splashscreen,hide)
10-15 13:36:05.149: D/FileTransfer(16158): download http://www.------.com/fx/json/publication.php?v=1.0.25&authid=------&groupid=------------ to cdvfile://localhost/persistent//com.------.------/-----------.json
10-15 13:36:05.150: D/FileTransfer(16158): Download file:http://www.------.com/fx/json/publication.php?v=1.0.25&authid=------&groupid=-------------
10-15 13:36:05.237: D/FileTransfer(16158): download http://www.------.com/fx/json/catalog.php?v=1.0.25&authid=------ to cdvfile://localhost/persistent//com.-----.------/data/catalog.json
10-15 13:36:05.242: D/FileTransfer(16158): Download file:http://www.------.com/fx/json/catalog.php?v=1.0.25&authid=------
10-15 13:36:05.784: D/FileTransfer(16158): Saved file: cdvfile://localhost/persistent//com.------.------/data/catalog.json
10-15 13:36:05.819: D/FileTransfer(16158): Saved file: cdvfile://localhost/persistent//com.------.------/------------.json
Unfortunately, even after trying a quick Google search, I don't know a way of grabbing logs from the Fire HD 6 when the signed APK runs. Does anyone have any idea about finding those logs on the device?
Here is the logcat from the sideloaded APK:
D/CordovaActivity(32519): onMessage(exit,null)
I/ActivityManager( 535): START u0 {xxxx} from pid 1208
I/Activity(32519): No ActvityExender defined. Proceed with default activity behavior.
I/CordovaLog(32519): Changing log level to DEBUG(3)
D/Whitelist(32519): Unlimited access to network resources
D/CordovaActivity(32519): CordovaActivity.onCreate()
D/CordovaActivity(32519): Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml
D/CordovaActivity(32519): Setting integer properties in CordovaActivity will be deprecated in 3.0 on July 2013, please use config.xml
W/BindingManager(32519): Cannot setInForeground() - never saw a connection for the pid: 32519
D/AmazonTransitionManager( 535): openingActivityName = com.branded.-----.BrandedActivity, animationType = ZOOM
D/CordovaWebView(32519): CordovaWebView is running on device made by: Amazon
D/JsMessageQueue(32519): Set native->JS mode to 2
D/CordovaActivity(32519): CordovaActivity.init()
D/CordovaWebView(32519): loadUrlIntoView(file:///android_asset/www/index.html, 12000)
D/CordovaActivity(32519): onMessage(splashscreen,show)
D/CordovaWebView(32519): >>> loadUrl(file:///android_asset/www/index.html)
D/PluginManager(32519): init()
D/CordovaWebView(32519): >>> loadUrlNow()
W/BindingManager(32519): Cannot setInForeground() - never saw a connection for the pid: 0
W/BindingManager(32519): Cannot setInForeground() - never saw a connection for the pid: 32519
I/CordovaLog(32519): Changing log level to DEBUG(3)
D/Whitelist(32519): Unlimited access to network resources
D/CordovaActivity(32519): Resuming the App
D/CordovaActivity(32519): CB-3064: The errorUrl is null
D/SoftKeyboardDetect(32519): Ignore this event
I/ActivityManager( 535): Displayed com.branded.-----/.BrandedActivity: +142ms
D/SoftKeyboardDetect(32519): Ignore this event
D/CordovaActivity(32519): onMessage(onPageStarted,file:///android_asset/www/index.html)
D/SoftKeyboardDetect(32519): Ignore this event
I/ActivityManager( 535): Process android.process.acore (pid 28595) has died.
I/ActivityManager( 535): Process com.ivona.tts.oem (pid 31488) has died.
D/CordovaWebViewClient(32519): onPageFinished(file:///android_asset/www/index.html)
D/CordovaActivity(32519): onMessage(onPageFinished,file:///android_asset/www/index.html)
D/CordovaActivity(32519): onMessage(spinner,stop)
D/CordovaNetworkManager(32519): Connection Type: wifi
E/chromium(32519): [ERROR:gl_context.cc(53)] Not implemented reached in virtual void gfx::GLContext::SetUnbindFboOnMakeCurrent()
I/chromium(32519): [INFO:async_pixel_transfer_manager_android.cc(60)] Async pixel transfers not supported
D/CordovaNetworkManager(32519): Connection Type: wifi
D/CordovaActivity(32519): onMessage(networkconnection,wifi)
I/ActivityManager( 535): Process com.smartcom.attwifi (pid 27770) has died.
W/ActivityManager( 535): Scheduling restart of crashed service com.smartcom.attwifi/com.smartcom.libwispr.MainWifiService in 1000ms
D/CordovaLog(32519): file:///android_asset/www/app.js: Line 1 : a launch right here: file:///android_asset/www/index.html
I/chromium(32519): [INFO:CONSOLE(1)] "a launch right here: file:///android_asset/www/index.html", source: file:///android_asset/www/app.js (1)
W/PackageManager( 535): Launching com.smartcom.attwifi (32109) with AMZ_APP_GID
I/ActivityManager( 535): Start proc com.smartcom.attwifi for service com.smartcom.attwifi/com.smartcom.libwispr.MainWifiService: pid=32727 uid=32109 gids={72109, 3003, 9001}
I/wpa_supplicant(31391): wlan0: CTRL-EVENT-SCAN-STARTED
D/CordovaActivity(32519): onMessage(spinner,stop)
Finally, does anyone have any idea why I'm seeing this bug? Or any ideas if building the Cordova jar differently would introduce this bug? Or why the Fire HDs are the only devices that have the issue? Or if this is a Sencha Touch/Cordova issue on Fire HDs? Or does anyone have any ideas for troubleshooting - I've run out of 'try this next' scenarios?
Thanks for reading and any help you provide, I do appreciate it!
It turns out that the key to a fix was the rotation piece I mentioned. I added a couple of these lines during the launch function of the Sencha Touch project's app.js:
Ext.Viewport.fireEvent('orientationchange');
Here is the app.js launch function after I added them:
launch: function() {
Ext.Viewport.bodyElement.on('resize', Ext.emptyFn, this, { buffer: 1});
Ext.Viewport.fireEvent('orientationchange');
console.log('a launch right here: '+window.location);
if (window.device.platform) {
try{
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
0,
function(fSys) {
console.log('index: gotFS');
window.fsRoot = fSys.root;
console.log('here is the root: '+window.fsRoot.toURL());
// Create the main viewport
setTimeout(function(){
Ext.Viewport.add( Ext.create('-------.view.Main') );
Ext.Viewport.fireEvent('orientationchange');
}, 100);
},
function(err) {
console.log("FileSystem Failure: " + err.code);
}
);
}catch(e){
//Any other error
alert('Could not open filesystem, errorcode: ' + e);
}
}else {
window.Dlog('no device platform found');
setTimeout(function(){
Ext.Viewport.add( Ext.create('-------.view.Main') );
}, 100);
}
},