Monkeyc command line errors

Hi folks, 

Been scratching my head for a while with this so hoping someone can lend a hand. Till now I've been creating and testing my apps in Eclipse and this works well if a bit cumbersome. I'd like to be able to use Atom to write the code and launch the simulator via the command line but when trying to do this I'm facing no end of errors.

Workflow looks like this:

9:33:16 ------------------------------------------------------------
» connectiq
9:33:38 ------------------------------------------------------------
» monkeyc -o bin/app.prg -f monkey.jungle -y /path/to/dev/key -d fenix5splus -w

However, I am being shown the following error

ERROR: Provided device id 'fenix5splus' is invalid.
com.garmin.monkeybrains.ParameterException: Provided device id 'fenix5splus' is invalid.
	at com.garmin.monkeybrains.Monkeybrains.run(Monkeybrains.java:2143)
	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:252)
	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:234)
	at com.garmin.monkeybrains.Monkeybrains.main(Monkeybrains.java:281)
usage: monkeyc [-a <arg>] [-d <arg>] [-e] [--Eno-invalid-symbol] [-f <arg>] [-g]
       [-h] [-i <arg>] [-m <arg>] [-o <arg>] [-p <arg>] [-r] [-s <arg>] [-t] [-u
       <arg>] [-v] [-w] [-x <arg>] [-y <arg>] [-z <arg>]
-a,--apidb <arg>       API import file
-d,--device <arg>      Target device
-e,--package-app       Create an application package.
   --Eno-invalid-symbolDo not error when a symbol is found to be invalid
-f,--jungles <arg>     Jungle files
-g,--debug             Print debug output
-h,--help              Prints help information
-i,--import-dbg <arg>  Import api.debug.xml
-m,--manifest <arg>    Manifest file
-o,--output <arg>      Output file to create
-p,--project-info <arg>projectInfo.xml file to use when compiling
-r,--release           Strip debug information
-s,--sdk-version <arg> SDK version to target
-t,--unit-test         Enables compilation of unit tests
-u,--devices <arg>     devices.xml file to use when compiling
-v,--version           Prints the compiler version
-w,--warn              Show compiler warnings
-x,--excludes <arg>    Add annotations to the exclude list
-y,--private-key <arg> Private key to sign builds with
-z,--rez <arg>         Resource file

I've tried other device id's to no avail.
Looking at my Eclipse console when the run command is executed I see:

BUILD: /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar /Users/avdi/gitspace/connectiq/connectiq-sdk-mac-3.0.11-2019-4-30-cd45859/bin/monkeybrains.jar -o /Users/avdi/gitspace/garmin/watch-faces/app/bin/app.prg -w -y /path/to/dev/key -d fenix5splus_sim -s 3.0.0 -f /Users/avdi/gitspace/garmin/watch-faces/app/monkey.jungle

If I try to run the monkeyc command in a similar way on the command line I get the following errors

9:44:38 ------------------------------------------------------------
» monkeyc -o bin/app.prg -f monkey.jungle -y /path/to/dev/key -d fenix5splus -s 3.0.0 -w
ERROR: Provided device id 'fenix5splus' is invalid.
com.garmin.monkeybrains.ParameterException: Provided device id 'fenix5splus' is invalid.
	at com.garmin.monkeybrains.Monkeybrains.run(Monkeybrains.java:2143)
	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:252)
	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:234)
	at com.garmin.monkeybrains.Monkeybrains.main(Monkeybrains.java:281)
usage: monkeyc [-a <arg>] [-d <arg>] [-e] [--Eno-invalid-symbol] [-f <arg>] [-g]
       [-h] [-i <arg>] [-m <arg>] [-o <arg>] [-p <arg>] [-r] [-s <arg>] [-t] [-u
       <arg>] [-v] [-w] [-x <arg>] [-y <arg>] [-z <arg>]
-a,--apidb <arg>       API import file
-d,--device <arg>      Target device
-e,--package-app       Create an application package.
   --Eno-invalid-symbolDo not error when a symbol is found to be invalid
-f,--jungles <arg>     Jungle files
-g,--debug             Print debug output
-h,--help              Prints help information
-i,--import-dbg <arg>  Import api.debug.xml
-m,--manifest <arg>    Manifest file
-o,--output <arg>      Output file to create
-p,--project-info <arg>projectInfo.xml file to use when compiling
-r,--release           Strip debug information
-s,--sdk-version <arg> SDK version to target
-t,--unit-test         Enables compilation of unit tests
-u,--devices <arg>     devices.xml file to use when compiling
-v,--version           Prints the compiler version
-w,--warn              Show compiler warnings
-x,--excludes <arg>    Add annotations to the exclude list
-y,--private-key <arg> Private key to sign builds with
-z,--rez <arg>         Resource file

9:45:13 ------------------------------------------------------------
» monkeyc -o bin/app.prg -f monkey.jungle -y /path/to/dev/key -d fenix5splus_sim -s 3.0.0 -w
ERROR: null
java.lang.NullPointerException
	at com.garmin.monkeybrains.devices.SimDevice.<init>(SimDevice.java:12)
	at com.garmin.monkeybrains.Monkeybrains.run(Monkeybrains.java:2138)
	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:252)
	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:234)
	at com.garmin.monkeybrains.Monkeybrains.main(Monkeybrains.java:281)
usage: monkeyc [-a <arg>] [-d <arg>] [-e] [--Eno-invalid-symbol] [-f <arg>] [-g]
       [-h] [-i <arg>] [-m <arg>] [-o <arg>] [-p <arg>] [-r] [-s <arg>] [-t] [-u
       <arg>] [-v] [-w] [-x <arg>] [-y <arg>] [-z <arg>]
-a,--apidb <arg>       API import file
-d,--device <arg>      Target device
-e,--package-app       Create an application package.
   --Eno-invalid-symbolDo not error when a symbol is found to be invalid
-f,--jungles <arg>     Jungle files
-g,--debug             Print debug output
-h,--help              Prints help information
-i,--import-dbg <arg>  Import api.debug.xml
-m,--manifest <arg>    Manifest file
-o,--output <arg>      Output file to create
-p,--project-info <arg>projectInfo.xml file to use when compiling
-r,--release           Strip debug information
-s,--sdk-version <arg> SDK version to target
-t,--unit-test         Enables compilation of unit tests
-u,--devices <arg>     devices.xml file to use when compiling
-v,--version           Prints the compiler version
-w,--warn              Show compiler warnings
-x,--excludes <arg>    Add annotations to the exclude list
-y,--private-key <arg> Private key to sign builds with
-z,--rez <arg>         Resource file

I've also checked the monkeyc script that is executed to make sure it is not being pulled from somewhere else and it looks like I've correctly set up monkeyc in my path.

9:47:15 ------------------------------------------------------------
» which monkeyc      
/Users/avdi/gitspace/connectiq/bin/monkeyc
9:48:16 ------------------------------------------------------------
» cat `which monkeyc`
#!/bin/bash

MB_HOME="$( cd "$( dirname "$0" )" && pwd )"
java -classpath "$MB_HOME"/monkeybrains.jar com.garmin.monkeybrains.Monkeybrains "$@"

Initially I thought that the device id being invalid might be an issue with the manifext but I don't think that's the case

9:49:36 ------------------------------------------------------------
» cat monkey.jungle
project.manifest = manifest.xml
9:55:26 ------------------------------------------------------------
» cat manifest.xml
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
    <iq:application entry="app" id="3e5f9f2298bb49deaa1b819ee9aa694f" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="2.3.0" name="@Strings.AppName" type="watchface" version="2.6.1">
        <iq:products>
            <iq:product id="approachs60"/>
            <iq:product id="d2charlie"/>
            <iq:product id="d2delta"/>
            <iq:product id="d2deltapx"/>
            <iq:product id="d2deltas"/>
            <iq:product id="fenix5"/>
            <iq:product id="fenix5plus"/>
            <iq:product id="fenix5splus"/>
            <iq:product id="fenix5x"/>
            <iq:product id="fenix5xplus"/>
            <iq:product id="fr245"/>
            <iq:product id="fr245m"/>
            <iq:product id="fr645"/>
            <iq:product id="fr645m"/>
            <iq:product id="fr935"/>
            <iq:product id="fr945"/>
            <iq:product id="marqathlete"/>
            <iq:product id="marqaviator"/>
            <iq:product id="marqcaptain"/>
            <iq:product id="marqdriver"/>
            <iq:product id="marqexpedition"/>
            <iq:product id="vivoactive3"/>
            <iq:product id="vivoactive3d"/>
            <iq:product id="vivoactive3m"/>
            <iq:product id="vivoactive3mlte"/>
        </iq:products>
        <iq:permissions>
            <iq:uses-permission id="UserProfile"/>
        </iq:permissions>
        <iq:languages>
            <iq:language>eng</iq:language>
        </iq:languages>
        <iq:barrels/>
    </iq:application>
</iq:manifest>

All this is running on the latest MacOS, I don't have a Windows / Linux machine to test on I'm afraid so hoping its a case of user error.

Let me know if I can provide further debug information.

  • I took a look at the command line shown in eclipse, and the problem is that for the sim, and I think you want to use

     -d fenix5splus_sim

    instead of

     -d fenix5splus

  • Thanks for the reply

    I already tried that, but it gives me an error that I posted above:

    9:45:13 ------------------------------------------------------------
    » monkeyc -o bin/app.prg -f monkey.jungle -y /path/to/dev/key -d fenix5splus_sim -s 3.0.0 -w
    ERROR: null
    java.lang.NullPointerException
    	at com.garmin.monkeybrains.devices.SimDevice.<init>(SimDevice.java:12)
    	at com.garmin.monkeybrains.Monkeybrains.run(Monkeybrains.java:2138)
    	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:252)
    	at com.garmin.monkeybrains.Monkeybrains.simpleMain(Monkeybrains.java:234)
    	at com.garmin.monkeybrains.Monkeybrains.main(Monkeybrains.java:281)
    usage: monkeyc [-a <arg>] [-d <arg>] [-e] [--Eno-invalid-symbol] [-f <arg>] [-g]
           [-h] [-i <arg>] [-m <arg>] [-o <arg>] [-p <arg>] [-r] [-s <arg>] [-t] [-u
           <arg>] [-v] [-w] [-x <arg>] [-y <arg>] [-z <arg>]
    -a,--apidb <arg>       API import file
    -d,--device <arg>      Target device
    -e,--package-app       Create an application package.
       --Eno-invalid-symbolDo not error when a symbol is found to be invalid
    -f,--jungles <arg>     Jungle files
    -g,--debug             Print debug output
    -h,--help              Prints help information
    -i,--import-dbg <arg>  Import api.debug.xml
    -m,--manifest <arg>    Manifest file
    -o,--output <arg>      Output file to create
    -p,--project-info <arg>projectInfo.xml file to use when compiling
    -r,--release           Strip debug information
    -s,--sdk-version <arg> SDK version to target
    -t,--unit-test         Enables compilation of unit tests
    -u,--devices <arg>     devices.xml file to use when compiling
    -v,--version           Prints the compiler version
    -w,--warn              Show compiler warnings
    -x,--excludes <arg>    Add annotations to the exclude list
    -y,--private-key <arg> Private key to sign builds with
    -z,--rez <arg>         Resource file

    It definitely looks as if appending `_sim` seems to change the behaviour of the monkeyc script, but I'm not really sure why it throws a NullPointerException on the CLI only.

  • which sdk?

    Here's the command line for one of my apps as used by eclipse wirge the 3.1.0-beta3 SDK.  Maybe your missing something:

    BUILD: C:\Program Files\Java\jre1.8.0_201\bin\java -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar C:\CIQ\connect-iq\connectiq-sdk-win-3.1.0.Beta3-2019-06-14-bf21fff97\bin\monkeybrains.jar -o C:\Users\James\workspace-prod\CIQpi\bin\CIQpi.prg -w -y "C:\Users\James\Google Drive\CIQ.key" -d fenix5plus_sim -s 3.1.0 -f C:\Users\James\workspace-prod\CIQpi\monkey.jungle 

  • I ran into a similar problem while trying to debug the compiler last week. In my case the problem was occurring because the devices.xml that was being found (when launching monkeybrains.jar) did not have entries for the device that I was trying to build with. I'm assuming that the problem you're seeing is similar.

    According to the output you've pasted above, when running eclipse, the console output shows the monkeybrains jar being invoked is:

    /Users/avdi/gitspace/connectiq/connectiq-sdk-mac-3.0.11-2019-4-30-cd45859/bin/monkeybrains.jar

    But when you're running the build directly, it is finding the monkeyc script in

    /Users/avdi/gitspace/connectiq/bin/monkeyc

    Unless you have some interesting file linking, I'm pretty sure that these are two different SDK installs. Try invoking monkeyc from the 3.0.11 SDK explicitly:

    /Users/advi/gitspace/connectiq/connectiq-sdk-mac-3.0.11-2019-4-30-cd45859/bin/monkeyc -o bin/app.prg -f monkey.jungle -y /path/to/dev/key -d fenix5splus_sim -s 3.0.0 -w

    If that works, I think you're going to want to tweak your PATH to refer to the bin folder for the SDK that you want to be using. Given the locations of these files, it looks like you have one SDK install nested inside another. This shouldn't hurt anything, but it might be a good idea to separate them just to keep things sane.

    Also note that I found and fixed the NullPointerException issue last week, so that has already been taken care of.

  • Hi ,

    Really appreciate the help, I think you managed to hit the nail on the head with your answer, I've managed to get back my monkeyc errors. I think I might go down the route of reinstalling ConnectIQ and cleaning up my path, but before I do that, I'm now hitting an issue with monkeydo, I was wondering if you could point me in the right direction

    9:39:40 ------------------------------------------------------------
    » /Users/avdi/gitspace/connectiq/connectiq-sdk-mac-3.0.11-2019-4-30-cd45859/bin/connectiq
    9:39:54 ------------------------------------------------------------
    » /Users/avdi/gitspace/connectiq/connectiq-sdk-mac-3.0.11-2019-4-30-cd45859/bin/monkeyc -o bin/app2.prg -f monkey.jungle -y /path/to/dev/key -d fenix5splus_sim
    9:40:06 ------------------------------------------------------------
    » ls bin
    app.prg              app2-settings.json   app2.prg.debug.xml
    app-settings.json    app.prg.debug.xml    app2.prg
    9:40:16 ------------------------------------------------------------
    » /Users/avdi/gitspace/connectiq/connectiq-sdk-mac-3.0.11-2019-4-30-cd45859/bin/monkeydo bin/app2.prg fenix5splus_sim
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    	at com.garmin.monkeybrains.prgreader.EntryPoint.parse(EntryPoint.java:71)
    	at com.garmin.monkeybrains.prgreader.EntryPoints.parse(EntryPoints.java:21)
    	at com.garmin.monkeybrains.prgreader.PrgParser.parse(PrgParser.java:50)
    	at com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux.execute(MonkeyDoDeux.java:243)
    	at com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux.main(MonkeyDoDeux.java:145)
    Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
    	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
    	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    	... 5 more

  • It looks like you're using Java 9, which has deprecated the javax/xml/bind functionality we're using. According to JEP320, you should be able to invoke java with --add-modules java.xml.bind, but this is not something I've tried to do.

    Until we port to a more recent version of Java, the simplest solution is to stick to Java 8.

  • Thanks you nailed it!
    I was able to launch via the command line, finally Tada

    Point of note for anyone who might read this in the future, I didn't have to specify my device with the `_sim` suffix. In fact when I did that the simulator wouldn't launch.

  • Glad you got it worked out. I'm not sure what the issue is with the `_sim` suffix. You said earlier that eclipse worked properly, but according to your output pasted above, the plugin was using -d fenix5splus_sim, so it surprises me that it doesn't work when invoking it directly.

  • Yup, Eclipse works properly and when I look at the output in the console when Eclipse starts the simulator `-d *_sim` is shown.

    For some reason trying to run it via the CLI requires me to drop the `_sim` suffix.
    Really I thought to mention it in case someone else has as broken a setup as me, it might be helpful Shrug‍♂️

    I'll probably try a fresh install of the ConnectIQ SDK to correct some of the setup issues I've clearly got myself in, do Garmin have a repo for their docs where contributions can be made?

  • Nope. All of our documentation is maintained internally. :(