Hi everyone,
I'm developing a simple application/widget and I'm stuck on a persistent compilation error when targeting the Forerunner 955 (fr955
) using Connect IQ SDK version 8.1.1.
The Error:
The compiler throws the following error on the getInitialView
function definition line (line 147 in my current file):
ERROR: fr955: Cannot override '$.Toybox.Application.AppBase.getInitialView' with a different return type. Object of type '$.Toybox.Lang.Array<...>' does not match return type 'PolyType<$.Toybox.Lang.Array[$.Toybox.WatchUi.Views] or $.Toybox.Lang.Array[$.Toybox.WatchUi.Views, $.Toybox.WatchUi.InputDelegates]>'.
My Code:
------------------------
import Toybox.Application;
import Toybox.WatchUi;
// ... other imports ...
import Toybox.Lang;
import Toybox.System;
// --- View Class (PointCalView) is defined above, seems OK ---
// class PointCalView extends WatchUi.View { ... }
// --- Application Class ---
class PointCalApp extends Application.AppBase {
// Member variable to hold the single view instance
var mainView as PointCalView?;
function initialize() {
AppBase.initialize();
mainView = null;
System.println("PointCalApp initialized.");
}
// getInitialView function causing the error (around line 147)
// Note: No explicit return type hint on the signature
function getInitialView() {
if (mainView == null) {
System.println("Creating mainView instance.");
mainView = new PointCalView();
} else {
System.println("Returning existing mainView instance.");
}
// Note: No explicit cast on the return value
return [ mainView ];
}
// onStart, onResponse, onStop methods are here...
// They seem to work fine based on console logs (API call successful,
// data parsed, mainView.updatePoints called correctly on the stored instance)
// ... (onStart, onResponse, onStop code can be included if needed, but the error points to getInitialView)
}
// --- Entry Point ---
function main() as Application.AppBase {
var app = new PointCalApp();
return app;
}
------------------------
Here's the relevant part of my PointCalApp.mc
file, including the PointCalApp
class and the getInitialView
function:
Troubleshooting Done:
- I have confirmed that the rest of the application logic (API calls, data parsing, updating the view's variables via
mainView.updatePoints()
) works correctly based on extensive console logging. The view variables do get the correct values. - I initially had explicit return type hints (
as ...
) on thegetInitialView
signature and/or casts (as ...
) on thereturn
statement, which also caused this error. - I have removed all explicit type hints and casts from
getInitialView
and itsreturn
statement, as shown in the code above. - I have performed clean builds (deleting the
bin
folder). - The error persists specifically for the
fr955
target with SDK 8.1.1
My Question:
What could be causing this persistent return type mismatch for getInitialView
on fr955
with this SDK version? What is the exact expected signature or return type structure that I should be using? Is there any known issue or workaround?
Thanks in advance for any help!