Search code examples
imageresourcespebble-sdk

Pebble app not recognizing Resource Images


I have added the resources via the 'add new' button next to resources and then in my code I am executing

image_logo = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_APP_LOGO_LONG);

but I am getting the following compilation error:

../src/main.c: In function 'main':
../src/main.c:120:44: error: 'RESOURCE_ID_IMAGE_APP_LOGO_LONG' undeclared (first use in this function)
../src/main.c:120:44: note: each undeclared identifier is reported only once for each function it appears in
Waf: Leaving directory `/tmp/tmpGhVqKn/build'
Build failed

Here is what my appinfo.json file contains, I downloaded this from the settings section for the app. You can see that the images have been added with the same identifier.

{
    "appKeys": {
        "agency": 0,
        "cleanStops": 11,
        "error": 10,
        "eta": 8,
        "getEta": 9,
        "getRoutes": 5,
        "index": 1,
        "refresh": 4,
        "routeId": 6,
        "routeName": 7,
        "stopId": 2,
        "stopName": 3
    },
    "capabilities": [
        "location",
        "configurable"
    ],
    "companyName": "joshua103us@yahoo.com",
    "longName": "DoublePebble",
    "projectType": "native",
    "resources": {
        "media": [
            {
                "file": "images/doublemap_menu_icon.png",
                "menuIcon": true,
                "name": "IMAGE_DOUBLEMAP_MENU_ICON",
                "type": "png"
            },
            {
                "file": "images/spoon_long_med-2.png",
                "name": "RESOURCE_ID_IMAGE_APP_LOGO_LONG",
                "type": "png"
            }
        ]
    },
    "sdkVersion": "3",
    "shortName": "DoublePebble",
    "targetPlatforms": [
        "aplite",
        "basalt"
    ],
    "uuid": "409b7111-c0bf-43bd-a90c-8a44c33d1eb3",
    "versionLabel": "1.0",
    "watchapp": {
        "watchface": false
    }
}

Solution

  • The RESOURCE_ID_ part of the resource identifier is added by the system to the name you specify in appinfo.json

    For example:

    {
      "file": "images/doublemap_menu_icon.png",
      "menuIcon": true,
      "name": "IMAGE_DOUBLEMAP_MENU_ICON",
      "type": "png"
    },
    

    You would then use RESOURCE_ID_DOUBLEMAP_MENU_ICON.