Acknowledged

Application.AppBase.weak() causes Unexpected Type Error in simulator but not on device

See title. Since downloading the latest updates for my devices in the SDK Manager, my app will not start up in the simulator.

I traced it to an error that is being thrown during initialization. Here is roughly what my code looks like:

class MyMenu extends WatchUi.View {
function initialize(app as Application.AppBase, ...) {

WatchUi.View.initialize();

self.app = app.weak();
...
}
}

And here is the error message:

Error: Unexpected Type Error Details: Failed invoking <symbol> Stack: - initialize() at /Users/bostonwalker/Projects/codex/source/menu/menu.mc:44 0x10006ed3 - initialize() at /Users/bostonwalker/Projects/tactidex/source/tactidexMenu.mc:15 0x10002d24 - buildMenu() at /Users/bostonwalker/Projects/tactidex/source/tactidexApp.mc:606 0x100024f7 - initialize() at /Users/bostonwalker/Projects/tactidex/source/tactidexApp.mc:54 0x1000004e

I wanted to figure out what is causing the type error so I ran the app on a physical device (Fenix 6 Pro), but found that it runs fine there.

Also, this code worked fine in April of this year when I first built against SDK 4.1.2. The latest updates in the SDK manager seem to have broken it. I am still building against 4.1.2.

Thanks for your help.

  • Here is a minimal reproducible example by adding one line to the initialize() method of a new test application (SDK 4.1.2, Device: Fenix 6 Pro):

    import Toybox.Application;
    import Toybox.Lang;
    import Toybox.WatchUi;
    
    class testApp extends Application.AppBase {
    
        function initialize() {
            AppBase.initialize();
            self.weak();
        }
    
        // onStart() is called on application start up
        function onStart(state as Dictionary?) as Void {
        }
    
        // onStop() is called when your application is exiting
        function onStop(state as Dictionary?) as Void {
        }
    
        // Return the initial view of your application here
        function getInitialView() as Array<Views or InputDelegates>? {
            return [ new testView(), new testDelegate() ] as Array<Views or InputDelegates>;
        }
    
    }
    
    function getApp() as testApp {
        return Application.getApp() as testApp;
    }

  • Any help available here? As of right now this is preventing me from releasing urgently needed fixes and updates to my app.

    I have to say I am very disappointed by the lack of visibility/control over which simulator updates are being downloaded by the SDK manager, which versions of the SDK correspond to which device firmwares, and the fact that you are implementing breaking changes to the language (Monkey types) within minor version updates of the SDK.

  • try: var app as Lang.WeakReference;

    Var self.app is already declared as Lang.WeakReference, sorry I neglected to include that line in my code snippet.