Error accessing RunningDynamics

Hi! I am trying to access RunningDynamics data, but i run into problems. I created a very simple example how to reproduce it:

using Toybox.WatchUi;
using Toybox.AntPlus;

class RunDynTest1View extends WatchUi.SimpleDataField {

    var MyDevice = null;
    
    // Set the label of the data field here.
    function initialize() {
        SimpleDataField.initialize();
        label = "Cadence";
        
        // is the Listener instead of null owrkaround still necessary?
        MyDevice = new AntPlus.RunningDynamics(new AntPlus.RunningDynamicsListener());
    }

    function compute(info) {
        var MyCadence = 1.0;
        var RunningDynamics = MyDevice.getRunningDynamics();
        if(RunningDynamics != null)    {
          MyCadence       = RunningDynamics.cadence;
        }       
        
        return MyCadence;
    }
}

I am aware that I don't get usable values while using the Simulator, but it should run. It runs fine in the Device Simulator, but when i make a "Run No Evil Test" run or sideload it to my watch, it crashes:

Error: Symbol Not Found Error
Details: Failed invoking <symbol>
Stack:
Encountered an app crash.

I am targeting a Fenix 6 and chose SDK version 3.0. I tried writing a log file by creating a text file with the name of my app in the log directory on my watch, but i didn't get helpful information from there.

Any feedback would be welcome, thanks!

  • I think you cannot do this: new AntPlus.RunningDynamicsListener()

    If you want to use listener, you need to implement your own listener class which extends AntPlus.RunningDynamicsListener().

    Not sure what you mean about "listener workaround", using null should be just fine if you don't need listener.

  • Hi Kurev, that's true, i don't need a listener here. After encountering this error, i searched the discussions here and found something that's somehow close to what I am experiencing:

    https://forums.garmin.com/developer/connect-iq/f/discussion/224380/cannot-instantiate-runningdynamics-on-735xt-can-in-simulator

    There workaround i am mentioning is what seemed to be the solution there. I agree that i shouldn't use a listener if i don't need one, but I'm running out of ideas how to solve this so i gave it a try :)

    What i don't understand is, why does my code run in the simulator but not on my watch? Is there a way to debug issues like this? I even tried to write log messages all over my code, but it looks to me that the error occurs somewhere outside? 

  • You may want to null check MyDevice.  If it is null, that would explain the Symbol Not Found.

  • Hi Jim, thanks for your feedback. I did the null checks in my original program, but removed it in the sample program to save some lines ;) If I include the null check in this example, it still crashes:

    // ...
        function compute(info) {
        	var MyCadence = 1.0;
        	if(MyDevice == null)	{
        		return 100.0;
        	}
           	var RunningDynamics = MyDevice.getRunningDynamics();
    // ...

    I can see in the device simulator that the value remains 1.0 and doesn't change to 100.0 as it should when MyDevice equals to null. Again, performing a "Run No Evil Test" run results in the same crash:

    Error: Symbol Not Found Error
    Details: Failed invoking <symbol>
    Stack:
    Encountered an app crash.