Why my app can't run on device well ?

Former Member
Former Member


I don't know why the screen crash when flip to widget or back to watchface.
code:
function onUpdate(dc) {
var width = dc.getWidth();
var height = dc.getHeight();
// Get the current time and format it correctly
var timeFormat = "$1$:$2$";
var clockTime = Sys.getClockTime();
//var hours = clockTime.hour;
//if (!Sys.getDeviceSettings().is24Hour) {
// if (hours > 12) {
// hours = hours - 12;
// }
//} else {
// if (App.getApp().getProperty("UseMilitaryFormat")) {
// timeFormat = "$1$$2$";
// hours = hours.format("%02d");
// }
//}
//var timeString = Lang.format(timeFormat, [hours, clockTime.min.format("%02d")]);

// Update the view
//var view = View.findDrawableById("TimeLabel");
// view.setColor(App.getApp().getProperty("ForegroundColor"));
//view.setText(timeString);

//view.setColor(App.getApp().getProperty("ForegroundColor"));
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
//Ui.loadResource(Rez.Fonts.fntTime)
var font = Ui.loadResource(Rez.Fonts.fntTime);
var fontSize = 74;
dc.drawText(width/2-1, (height-74)*clockTime.hour/24.0f, font, clockTime.hour/10, Gfx.TEXT_JUSTIFY_RIGHT);
dc.drawText(width/2+1, (height-74)*clockTime.min/60.0f, font, clockTime.hour%10, Gfx.TEXT_JUSTIFY_LEFT);
//dc.setColor(Gfx.COLOR_LT_GRAY, Gfx.COLOR_LT_GRAY);
//dc.drawCircle(100, 100, 7);
ZDebug.log("updated time position"+(height-74));
// Call the parent onUpdate function to redraw the layout
//View.onUpdate(dc);
//Ui.animate(drawable, property, type, start, stop, period, callback)
}
  • You may want to use the format for the bug reports (the sticky at the top has it), as it's unclear as to the watch you're using, the SDK version, FW version, etc.

    But the first place to look (sounds like this happens on the watch and you don't see it in the sim), is looking at the \garmin\apps\logs\ciq_log.txt. If there's not much there, make sure you don't have the "Build release version of project" checked when you use the Build for device wizard, as you'll likely get for info in ciq_log.txt

    On some watches, I's seen something like that (your picture) when a CIQ watchface crashes, but it's often just like if you see a "IQ!" for a crash.
  • I've already provided the solution in the original post here.
  • Former Member
    Former Member
    I've already provided the solution in the original post here.


    I forgot the super update function:
    WatchFace.onUpdate(dc);
  • I forgot the super update function: WatchFace.onUpdate(dc);


    Not calling the base onUpdate() should not cause the application to crash; It would cause the background to not get cleared, but it should not cause a crash. Passing something that isn't a string as the fourth parameter to drawText() will cause a crash on every device I've ever tested (but it happens to work in the simulator).

    Travis