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.

  • Former Member
    0 Former Member over 5 years ago in reply to Travis.ConnectIQ

    How can I see what versions is eclipse ide using? Everything works there by default.

  • Former Member
    0 Former Member over 5 years ago in reply to Former Member

    Ok, I finally make it work by changing monkeydo script to this

        /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/bin/java -classpath "$MB_HOME"/monkeybrains.jar com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux -f "$PRG_PATH" -d $DEVICE_ID -s "$MB_HOME"/shell $TEST_FLAG $TEST_NAME

    To be honest, it should not use java directly and should use some of the available options on the path, like JAVA_HOME

  • Former Member
    0 Former Member over 5 years ago in reply to Former Member

    In any case, I'm still guessing why this works with eclipse ide, who seems to be using the same java version that I was using. Maybe eclipse plugin includes the required libraries? I hate eclipse, and I have no idea how to check this, but I would love to know it to make my projects a little bit more future proof

  • I believe the monkeyc script is doing the right thing. It invokes java directly because it expects the java executable that you want to use to be found in your PATH environment variable.

    If you want it to find the java in /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home/bin, then add that to the front of your PATH. Assuming you're using sh/bash:

    $ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
    $ export PATH=$JAVA_HOME/bin:$PATH

    You can then verify you're getting the right java..

    $ which java
    $ java -version

  • Former Member
    0 Former Member over 5 years ago in reply to Travis.ConnectIQ

    Ok, I'll try that. I didn't know that JAVA_HOME could affect the "java" command directly.

  • Former Member
    0 Former Member over 5 years ago in reply to Former Member

    Ok, thank you  very much. 

    This is my last working build script:

    SDK_HOME=/Users/danielo/garmin-sdk/connectiq-sdk-mac-3.1.4-2019-09-17-f1e7e9687
    DEVICE=fenix5
    appName=garmin-hello-world
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
    
    # Build
    "$SDK_HOME/bin/monkeyc" \
        --output "$(pwd)/bin/$appName.prg" \
        --private-key /Users/danielo/garmin-sdk/developer_key \
        --device $DEVICE \
        -s 3.0.0 \
        --warn \
        --jungles $(pwd)/monkey.jungle
    
    PATH=$JAVA_HOME/bin:$PATH $SDK_HOME/bin/monkeydo bin/${appName}.prg $DEVICE
    

  • As I understand it, JAVA_HOME doesn't affect the java command at all. It is just an environment variable that is typically set to the path the the active JDK.