Failed invoking <symbol>

Hello again,

Here is another error

I'm trying to instantiate a class but it says that :

Error: Illegal Access (Out of Bounds)
Details: Failed invoking <symbol>

Stack: 
  - initialize() .../jsonBackground.mc:14 0x10000023

the jsonBackground.mc file:

using Toybox.Background as Bg;
using Toybox.System as Sys;

// The Service Delegate is the main entry point for background processes
// our onTemporalEvent() method will get run each time our periodic event
// is triggered by the system.

(:background)
class JsonBackground extends Toybox.System.ServiceDelegate {
	//hidden var _transaction=null;
	
	function initialize() {
		Sys.ServiceDelegate.initialize();
		var ltd=new LoginTransactionDelegate();
	 	//_transaction = new LoginTransaction(ltd);
	}
		
    function onTemporalEvent() {
        System.print("onTemporalEvent");
        Bg.exit(1);
    }
    

}

the LoginTransactionDelegate class:

using Toybox.Background as Bg;
using Toybox.System as Sys;
using Toybox.Communications as Comm;
using Toybox.WatchUi as Ui;

// The Service Delegate is the main entry point for background processes
// our onTemporalEvent() method will get run each time our periodic event
// is triggered by the system.

// This is a TransactionDelegate for handling the login
class LoginTransactionDelegate extends TransactionDelegate{

    // Constructor
    function initialize() {
        TransactionDelegate.initialize();
    }

 	function handleResponse(data) {
       System.println("OK "+data);
    }
    
    function handleError(code) {
        var msg = "err";
        msg += code;
        System.println(msg); 
    }

}

Thanks in advance

  • Looks like your missing the background annotation on LoginTransactionDelegate and maybe TransactionDelegate

  • Once again a big thank, you nailed it

  • Hm,

    just starting to adapt my tools (fonteditor, screeny,...) to deal with the new SDK versions so I have not so much time for chekcing my watch apps - but yesterday may watch stopped working during an activity - because my datafield program crashes since the last firmware update on my FR935...

    Here's the error which appears as soon as I press the Start/Stop button:

    - onTimerStart() at C:\Program Files\System\Connect IQ\Samples\Datafield\Birdie\Source\Birdie.mc:239 0x1000063f

    Here's the source code - which still works perfect when using the SDK  2.2.6, the simulator also shows no crash. As soon I compile and start it with 3.1.5 the IQ-error symbol is seen after pressing the Start button...

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    // make Birdie brs!9* 9
    
    using Toybox.WatchUi as Ui;            // Oberflächeneinbindung
    using Toybox.Application as App;    // Programmeinstiegspunkt
    using Toybox.Graphics as Gfx;        // Graphikfunktionen
    using Toybox.Time as Time;            // atuelle Zeit etc.
    using Toybox.Activity as Act;        // Timer-Status
    //using Toybox.Math as Math;        // Mathematische Funktionen
    using Toybox.System as Sys;         // Debugging mit Sys.println();
    
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    class BirdField extends Ui.DataField {
    
        hidden var color;                // Farbe in 'paceshort'
        
        const colnull=-1;                                        // transparent
                
        hidden var timermode;                                    // Start / Stop
        hidden var timezone;
        hidden var time;
        hidden var dist;
        hidden var heart;
        hidden var altitude;
        hidden var medheart;
        hidden var pace;
        hidden var laptime;
        hidden var distcount;
        hidden var profile;
        hidden var profilename="";
        hidden var tmax,tmin;
        hidden var mx,my;
        hidden var numbers;
        hidden var bignumbers;
        hidden var infoplus;
        hidden var titlex;
        hidden var titlemode;
        hidden var notesx;
        hidden var notesy;
        hidden var notesmode;
        
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function reset()
        {    // Sys.println("[Reset]");
        
            var i;                                        // Werte zurücksetzen //
    
            profile=UserProfile.getCurrentSport();
            if (profile==0)
                { profilename="walk"; }                    // HIKING //
            else if (profile==1)
                { profilename="run"; }                    // FAST RUNNING //
            else if (profile==2)
                { profilename="bike tour"; }            // BIKING //
            else
                { profile=3; profilename="activity"; }    // TRAIL RUNNING //
            
            //trend=0;                                    // Pace bis zum vorigen Kilometer
            time=0;                                        // aktuelle Zeit
            dist=0;                                        // aktuelle Distanz
            laptime=0;                                    // Zeit beim letzten Kilometer
            distcount=1;                                // aktueller Kilometer
            
        }
        
        
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function updateTimerMode()
        {
            timermode=Act.getActivityInfo().timerState;
            // Sys.println("TIMER MODE "+timermode);
        }
        
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function initialize()
        {    // Sys.println("[Initialize]");
    
            var i;
            reset();
            
            timezone=Toybox.System.getClockTime().timeZoneOffset;
            
            // updateTimerMode();
                
            DataField.initialize();
            numbers=    Ui.loadResource(Rez.Fonts.numbers);
            bignumbers=    Ui.loadResource(Rez.Fonts.numbersmedium);
            
        }
    
    
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function timeshort(time)
        {
            var hour;
            var min;
            
            time=(time+timezone)%86400/60;
            hour=time/60;
            min=time%60;
            if (min<10)
            {    return hour+":0"+min;    }
            else    
            {    return hour+":"+min;    }
            
        }
        
    
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function compute(info)
        {
            // Sys.println("[Compute]");
            // called every second
            
            var i;
    
        
            dist=info.elapsedDistance;                // Aktivitätsdaten
            time=info.timerTime/1000;                // oder 'elapsedTime' (Zeit seit Start)
            time=time.toLong();
            
            // assertMessage(dist==null,"Distanz nicht definiert");
                
            if (dist==null)
                {    dist=0;    }
            else
                {    dist=dist.toLong();    }
    
            pace=info.currentSpeed;
            if (pace!=null && pace>0.01)            // Abfrage auf 'null' und größer Epsilon?
                {    pace=(1000/pace).toNumber();    }
            else
                {    pace=0;    }
            
            timermode=info.timerState;
            heart=info.currentHeartRate;
            medheart=info.averageHeartRate;            // Gesamtdurchschnitt
        
        }
    
    
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function onUpdate(dc)
        {
    /*    // if (time%5==0)
            {
                // Sys.println("[Time]"+time);
                redraw(dc);
            }
        }    
    
        function redraw(dc)
        {
    */
            var tick;
            var width;
            var text;
            var i,c,o;
            var x,y,z;
            var now=Time.now().value();
            
            var colback=getBackgroundColor();        // Hintergrund
            var coltext=0xFFFFFF-colback;            // Textfarbe (Vordergrund)
            var colmore=0x555555+coltext&0x555555;    // stärkerer Grauton
            var colless=0xFFFFFF-colmore;            // schwächerer Grauton
            
            dc.setColor(coltext,colback);
            dc.clear();
    
            // TIMER_STATE_STOPPED, TIMER_STATE_PAUSED, TIMER_STATE_ON, TIMER_STATE_OFF
            if (time==0 && timermode!=Act.TIMER_STATE_ON)
            {
                o=(titlemode==null)?0:35;
                c=(notesmode==null)?0:-40;
                
                c+=(my-10)<<1-o;
                z=(my>40)?60:0;
                i=o+(c-z)/2+c/30+((my==38 && titlemode==1)?-5:5);    // Layouts 3A und 4A
                
                // dc.drawText(mx,i,Gfx.FONT_MEDIUM,notesmode,Gfx.TEXT_JUSTIFY_CENTER);
                dc.drawText(mx,i,Gfx.FONT_MEDIUM,"Ready to start",Gfx.TEXT_JUSTIFY_CENTER);
                if (z)
                { dc.drawText(mx,i+34,Gfx.FONT_MEDIUM,"your "+profilename+"...",Gfx.TEXT_JUSTIFY_CENTER); }
        
            }
    
            else
    
            {
                dc.drawText(mx,my,Gfx.FONT_MEDIUM,time,Gfx.TEXT_JUSTIFY_CENTER);
            }
    
        }
        
    
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        function onLayout(dc)
        {
            var f;
            var obscurity=DataField.getObscurityFlags();
            var sx,sy;                    // global nicht erforderlich (mx,my reichen)
        
            sx=dc.getWidth();            // Displaybreite
            sy=dc.getHeight();            // Displayhöhe
            mx=sx/2;                    // Displaymittelpunkt
            my=sy/2;
            
            infoplus=44;                                                    // Zeit & Herzfrequenz
            titlex=mx+2; titlemode=Gfx.TEXT_JUSTIFY_CENTER;                    // Top Text (wegen '"'-Symbols etwas nach rechts)
            notesx=mx; notesy=sy-58; notesmode=Gfx.TEXT_JUSTIFY_CENTER;        // Bottom Text (wegen unwichtigem 'km'-Anhängsel etwas nach rechts, s.o.)
    
        }
    
        ////// ///// //// //// /// /// /// // // // // // / / / / / // // // // // /// /// /// //// //// ///// //////
        
        function onTimerStart()        { /* updateTimerMode(); */ Ui.requestUpdate();    }      /* ### */
        function onTimerStop()        { /* updateTimerMode(); */ }
        function onTimerPause()        { /* updateTimerMode(); */ }
        function onTimerResume()    { /* updateTimerMode(); */ }
        function onTimerLap()        { /* updateTimerMode(); */ }
        function onTimerReset()        { /* updateTimerMode(); */ reset(); }
    }
    
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    class Birdie extends App.AppBase
    {
        function getInitialView()    {    return [new BirdField()];    }
        function initialize()        {    AppBase.initialize();        }
        function onStart(state)        {                                }
        function onStop(state)        {    return false;                }
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Any idea why this behaviour is seen whitin the new version and how it can be fixed easily?

  • Try commenting out calls to Ui.requestUpdate().

    There's been a change related to that in data fields. 

  • Thanks, looks fine - will give it a try on my next activity ;)

  • Thanks! There was no mention in the documentation about the change and my data field worked fine in all the emulators, but crashed in device. Now it works fine.