Too Many Arguments Error

We added a functionality in the 2.1.2 SDK release to perform an argument count check on function and method calls. This was included as part of a larger security effort, which includes things like app signing and encryption of app data. Overall, this is a good thing, since it promotes more robust source code prevents some potential security exploits. Unfortunately, it has also caused some apps to crash on 1.3.x and 2.1.x devices when built with the 2.1.2 SDK even though these same apps execute without issue when built with earlier SDK releases. This kind of crash appears in the [FONT=courier new]CIQ_LOG.txt[/FONT] file as a "Too many arguments" error, signifying the argument count check has failed.

In most cases, the culprits behind this "Too many arguments" issue are missing [FONT=courier new]'state'[/FONT] arguments for [FONT=courier new]onStart()[/FONT] and [FONT=courier new]onStop()[/FONT]. These are currently unused argument and were passed implicitly in earlier versions of Connect IQ, but must now be included explicitly. Another example that can cause this is something like an [FONT=courier new]initialize()[/FONT] function for a Drawable, which takes an array of options but to which none are passed.

The new minimum SDK selector is designed to build for the highest supported SDK for each device. For example, consider this set of devices: device A (2.1.x), B (1.3.x), and C (1.2.x). The table below illustrates how the build system is designed to function:

[TABLE="width: 750, align: left"]
[TR]
[TD]Minimum SDK Selected
[/TD]
[TD]Available Target Devices
[/TD]
[TD]What We Build
[/TD]
[/TR]
[TR]
[TD]2.1.x[/TD]
[TD]A[/TD]
[TD]2.1.x PRG for A[/TD]
[/TR]
[TR]
[TD]1.3.x[/TD]
[TD]A, B[/TD]
[TD]2.1.x PRG for A, 1.3.x PRG for B,[/TD]
[/TR]
[TR]
[TD]1.2.x[/TD]
[TD]A, B, C[/TD]
[TD]2.1.x PRG for A, 1.3.x PRG for B, 1.2.x PRG for C[/TD]
[/TR]
[/TABLE]
It can sometimes be difficult to troubleshoot this issue due to a bug in our build system. The Build For Device Wizard may build a PRG for a target VM version lower than expected for a given device. The result is that a PRG made with the Build For Device Wizard will operate without issue on a device, but the same app will fail with a "Too many arguments" error when using a PRG from the App Export Wizard (i.e. installed from the store). As a consequence, it can be difficult to obtain a useful call stack in the [FONT=courier new]CIQ_LOG.txt[/FONT]. We have a fix for this that will be included in an upcoming release of the SDK.

Our apologies for frustration this error has caused for some of you. Our goal is to avoid breaking changes unless necessary, and we didn't anticipate this would have this kind of impact. If you continue to encounter this issue and are unable to find a resolution, please contact the Connect IQ team directly at [EMAIL="[email protected]"][email protected][/EMAIL] for assistance. We'll be glad to help you out!

- The Connect IQ Team