I keep getting a "Device is not set" crash

This one is getting annoying. 

I previously changed the launch.json in accordance with forums.garmin.com/.../vs-code---start-debugging---device-selection

I am trying to learn how to do menu2. I created a basic watch face with options (straight from VS).  I then tried to add a toggle menu option (Jim, your ComplexWF is helpful, but the shorthand and multiple items make it a bit..Complex (haha)).  I can get the app to execute up until the simulator opens and I get a "Device not set" crash error. I only have 1 device as an option.  Usually, when I execute my apps to test, it asks me for the device I want to test.  It is not doing it, just crashing.

Any help?

Thanks

  • Sounds like your launch.json is incorrect

  • Except it worksd with my 5 other watch faces? So, I'm not sure what I should change...

  • R U sure it's the same? I always copy it from a previous project. Why you write that you changed it?

  • OK.  What am I missing?

    I first tried creating an unaltered watch face using the template.  Un-edited, I cannot run it in the simulator.  Soo...

    There is one runProgram.js file (Mac) and I've changed it to

    if (e.exitCode === 0) {
    workspace === null || workspace === void 0 ? void 0 : workspace.setDirty(false);
    workspace === null || workspace === void 0 ? void 0 : workspace.setLastBuildDevice();
    }
    }

    I figured out how to get to my settings.json file in VS and tried adding 

        "version": "0.2.0",
        "configurations": [
    
            {
                "type": "monkeyc",
                "request": "launch",
                "name": "Run App",
                "stopAtLaunch": false,
                "device": "${command:GetTargetDevice}"
            },
            {
                "type": "monkeyc",
                "request": "launch",
                "name": "Run App",
                "stopAtLaunch": false,
                "device": "${command:GetTargetDevice}"
            },
            {
                "type": "monkeyc",
                "request": "launch",
                "name": "Run Complication Apps",
                "stopAtLaunch": false,
                "complicationSubscriberFolder": "${command:GetComplicationSubscriberFolder}",
                "complicationPublisherFolder": "${command:GetComplicationPublisherFolder}",
                "device": "${command:GetTargetDevice}"
            }
        ]
    }

    I pulled this from a file that works.

    I still cannot test.  What am I missing?

  • Hmm, have you noticed that the 1st and 2nd configuration are the same?

  • I did.  I figured it was supposed to be there for some random, unexplained reason.  Kind of like the complications in the last one, even though they are not used. (Please remember, for us amateurs there's no Monkey C training manual or learning course :D.  Either way, I removed one.  It didn't fix the glitch.

  • if you use "open folder" then you don't have to bother with launch.json configurations.

  • Why? The way you open the project has nothing to do with how you run the app in the simulator. Let's say you opened it that way, without launch.json, you run it once with device X, then how you run it again with device Y?

  • I don't have a single launch.json file on my computer.

    I've moved away from using workspaces since making the switch from eclipse to vscode and use open folder to open the project I want to work on.

    Pressing F5 I run the project.
    If I want to run for another device target I bring up the vscode menu and choose Monkey C: Build Project and then press F5 to run again.

    I'm aware that my workflow differs from how it's promoted by the connectiq dev team, but it works for me and I love it. :)

    // A disadvantage of my way of working is that I only have a single project open at 1 time, so if you are a copy paste lover it won't be for you.

  • I run "Monkey C: Build Current Project".  Then select "Run Without Debugging" and I get the same error.  It does the build part just fine, but still crashes on the run.