Does anyone else have problems pushing menu items in Venu Sq?


Source:
209 System.println("Resource String ID: " + Rez.Strings.fasting_stop);
210 System.println("Resource String: " + Ui.loadResource(Rez.Strings.fasting_stop));
211 System.println("Resource String ID: " + Rez.Strings.fasting_stop_sub);
212 System.println("Resource String: " + Ui.loadResource(Rez.Strings.fasting_stop_sub));
213 menu.addItem(new Ui.MenuItem(Rez.Strings.fasting_stop, Rez.Strings.fasting_stop_sub, :stop, null));

Output:
Resource String ID: 10629
Resource String: Stop Fast
Resource String ID: 9749
Resource String: fast timer is running

Error: Unhandled Exception
Exception: UnexpectedTypeException: Unexpected type, expected String or String Resource
Stack:
- setString() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:2892 0x30003215
- setLabel() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:2905 0x3000322e
- initialize() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:2869 0x30003123
- loadMenu() at /Users/andrezunido/Documents/Personal/development/eclipse-workspace/FastingWidget/source/common/delegates/FastingWidgetBehaviorDelegate.mc:213 0x10007ebf
- onMenu() at /Users/andrezunido/Documents/Personal/development/eclipse-workspace/FastingWidget/source/common/delegates/FastingWidgetBehaviorDelegate.mc:107 0x10007a95
- keyHandler() at /Users/andrezunido/Documents/Personal/development/eclipse-workspace/FastingWidget/source/common/delegates/FastingWidgetBehaviorDelegate.mc:128 0x10007b1f
- onKey() at /Users/andrezunido/Documents/Personal/development/eclipse-workspace/FastingWidget/source/common/delegates/FastingWidgetBehaviorDelegate.mc:28 0x1000793d
- handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1073 0x3000243a
- handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1262 0x30002673
unknown device message: [0]appCrashed 957F00001300F10901000000B8626A0A


No issues whatsoever in all other CiQ 3.2.0 devices except in the Venu Sq and Sq. Music Edition.

I'm stumped! Any ideas on how to fix/troubleshoot this?

  • It looks like you're trying to initialize MenuItem with by passing in string resource IDs (Symbols), instead of actual strings.

    But the docs say that the first two arguments to MenuItem.initialize() are Strings:

    https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/MenuItem.html

    What if you just change your code to:

    menu.addItem(new Ui.MenuItem(Ui.loadResource(Rez.Strings.fasting_stop), Ui.loadResource(Rez.Strings.fasting_stop_sub), :stop, null));

    If it works the other way on other devices (but the SDK docs do not indicate it should be so), then I would call that a bug and/or unspecified behavior that you should not rely on.

    EDIT: Now I see that the error message explicitly says a string resource should be allowed.

    Maybe it's a bug in the documentation then (as well as a bug in the simulator.)

    However, the code I suggested should hopefully work around this bug (or unexpected behavior).

  • Thanks for the hint.  

    Indeed it seems the docs do mention that it should only accept String objects. And it works in the Sq family when loading the string resource explicitly. 

    As I mentioned, this works fine for all other CiQ 3.2 compatible devices that I tested.  The error clearly points that resource IDs should be accepted too, so it's completely misleading. Weird thing is that I can only reproduce it in the Sq family when using the simulator (I don't have access to a physical Sq to test), Venu, Vivoactive and other similar devices don't have this problem. 

    I'm using Sdk 3.2.5. 

  • Did Garmin ever acknowledge this? ? I have run into this also except I can't fix it because my menu is in an XML menu resource, using string resources (so as to support multiple languages). It used to work but at some point it stopped working, I think SDK 3.2.4 is where is started breaking.

  • (:connectiq_3)
    function buildMenuItem(label, sub_label, id, opt) {
        return new Ui.MenuItem(
            forceStr(label),
            sub_label != null ? forceStr(sub_label) : null,
            id,
            opt
        );
    }
    
    // Needed to work-around limitation in Connect IQ ability to dynamically load string resources in Venu Sq (3.2.0)
    (:connectiq_3)
    function forceStr(str) {
        return str instanceof Toybox.Lang.String ? str : Ui.loadResource(str);
    }

    I'm not aware of any acknowledgement or "fix" in the latest releases (although that would be nice so I can clean my code).
    I'm handling it like this (see the snippet). Maybe there are better ways - very likely.
    Unfortunately I don't create the menus via an xml definition, I do it programatically so this probably doesn't help your case at all.

  • Yeah, this looks like a problem with the device .bin files. Filed as WERETECH-11125.

    I know what the problem is and know how to fix it. Just need the time.

  • Wicked! And also an ultra big thanks to for doing a test on an actual Venu Sq Music device with me late last night.

  • Hi

    Same issue with VENU and VENU2S on 4.0.1 of SDK

    Error: Unhandled Exception
    Exception: UnexpectedTypeException: Unexpected type, expected String or String Resource
    Stack:
    - setString() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:2892 0x30003215
    - setSubLabel() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:2927 0x30003256
    - initialize() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:2870 0x30003131
    - FctFieldsMenu() at C:\Users\Parents\workspace\APP4TRNEW\source\Default\GenViewInputDelegate.mc:342 0x10008a87
    - onSwipe() at C:\Users\Parents\workspace\APP4TRNEW\source\Default\GenViewInputDelegate.mc:317 0x1000897e
    - handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1086 0x300024ed
    - handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1262 0x30002673

    (:CIQ2HighMemory) function FctFieldsMenu() {
      //System.println("CIQ2HighMemoryFctFieldsMenu");
                    ifToybox.WatchUi  has :Menu2 ) {
                                            customFieldMenu = new WatchUi.Menu2({:title=>Rez.Strings.FieldMenuTitle});
     var AA=FieldgetString(arrayVariables[0]);
     var BB=WatchUi.loadResource(Rez.Strings.ChoixTitleV1);
     System.println("AA="+AA);
     System.println("BB="+BB);
                                     // this line is the crash     bellow
      customFieldMenu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.ChoixTitleV1), FieldgetString(arrayVariables[0]), :id30null));
                                     // this line is the crash     before
                                            customFieldMenu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.ChoixTitleV2), FieldgetString(arrayVariables[1]), :id31null));
                                            customFieldMenu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.ChoixTitleV3), FieldgetString(arrayVariables[2]), :id32null));
                                            customFieldMenu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.ChoixTitleV4), FieldgetString(arrayVariables[3]), :id33null));
                                            customFieldMenu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.ChoixTitleV5), FieldgetString(arrayVariables[4]), :id34null));
                                            customFieldMenu.addItem(new WatchUi.MenuItem(WatchUi.loadResource(Rez.Strings.ChoixTitleV6), FieldgetString(arrayVariables[5]), :id35null));
                                         

                                    WatchUi.pushView(customFieldMenunew Menu2FieldCustomDelegate(), WatchUi.SLIDE_UP );
                    }
  • I think this is now fixed. Or at least the way that I was running into it is fixed. I saw a series of device updates in the "SDK Manager" app this week, which I believe is related. Can you confirm, ?

  • Yes, we updated a handful of the simulator devices for this fix. I don't have the exact date that the fixes were made, but I believe the fix would have been pushed out between 4/23 and 5/7.