Jsapi.h not found

I’m using cocos2d-x 3.9. After importing iap, I see the following successful message:

Copyright © 2015 SDKBOX Inc. v1.0.0.2
downloading package sdkbox-iap_v2.0.2.0.tar.gz
[###################################] 100%
downloading package sdkbox-googleplayservices_v2.0.2.0.tar.gz
[###################################] 100%
Installation Successful :slight_smile:
Please reference the online documentation to finish the integration:
http://sdkbox-doc.github.io/en/plugins/iap/v3-js/
Installation Successful :slight_smile:

My first question is this: why does the link point to the js docs when my project is cpp? Is this just the default landing page?

After following the notices on the cpp page, the build fails in several header files that try to include ‘jsapi.h’ because the file can’t be found.

How can I fix this?

Interestingly, I did have to add the res folder so that it could copy the sdkbox_config.json into it. I was also prompted by xcode to link to storekit and enable in-app purchases, but I didn’t see that documented online. Please advise if this is normal.

Thanks for the help.

Interesting, so sdkbox mistakenly identify your project as cocos-js project…
Can you share your AppDelegate.cpp file? I think you just need to remove the js related functions.

#include "AppDelegate.h"
#include "MenuScene.h"

USING_NS_CC;

AppDelegate::AppDelegate() {

}

AppDelegate::~AppDelegate() 
{
}

//if you want a different context,just modify the value of glContextAttrs
//it will takes effect on all platforms
void AppDelegate::initGLContextAttrs()
{
    //set OpenGL context attributions,now can only set six attributions:
    //red,green,blue,alpha,depth,stencil
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};

    GLView::setGLContextAttrs(glContextAttrs);
}

// If you want to use packages manager to install more packages, 
// don't modify or remove this function
static int register_all_packages()
{
    return 0; //flag for packages manager
}

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
        glview = GLViewImpl::createWithRect("totToDot", Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
        glview = GLViewImpl::create("totToDot");
#endif
        director->setOpenGLView(glview);
    }

    // turn on display FPS
    director->setDisplayStats(false);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

    register_all_packages();

    // create a scene. it's an autorelease object
    auto scene = MenuScene::createScene();

    // run
    director->runWithScene(scene);

    return true;
}

// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
    Director::getInstance()->stopAnimation();

    // if you use SimpleAudioEngine, it must be pause
    // SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
    Director::getInstance()->startAnimation();

    // if you use SimpleAudioEngine, it must resume here
    // SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
}

After removing the added files and cleaning up the AppDelegate.cpp (shown above), the file fails to patch.

It’s fine that AppDelegate.cpp failed the patch it just means you have to call sdkbox.IAP.init() manually.

Ok, but I still get the jsapi.h error. Any ideas on how to resolve this?

Can you post the full error?

In file included from .../Classes/PluginIAPJS.cpp:1:
.../Classes/PluginIAPJS.hpp:4:10: fatal error: 'jsapi.h' file not found
#include "jsapi.h"
         ^
1 error generated.

These files were added to the project:
PluginIAPJS.cpp
PluginIAPJS.hpp
PluginIAPJSHelper.cpp
PluginIAPJSHelper.h
SDKBoxJSHelper.cpp
SDKBoxJSHelper.h

Are these the right files to add for a cpp project? Thanks

You should remove these files

Can you also post the result of sdkbox symbols command? I try to investigate why sdkbox thinks your project is a js project…

Thanks, it built fine without those js files. COCOS_PROJECT_TYPE is js. I’m guessing that I setup the project wrong from the beginning?

SDKBOX installer script symbols:
     ANDROID_ACTIVITY_NAME              AppActivity
     ANDROID_ACTIVITY_PATH              /Users/pwinward/projects/myProject/proj.android/src/org/cocos2dx/cpp/
     ANDROID_COCOS_PACKAGE_ROOT         /Users/pwinward/projects/myProject/cocos2d/cocos/platform/android/java/
     ANDROID_COCOS_SRC_DIR              /Users/pwinward/projects/myProject/cocos2d/cocos/platform/android/java/src/org/cocos2dx/lib/
     ANDROID_JNI_DIR                    /Users/pwinward/projects/myProject/proj.android/jni/
     ANDROID_LIBS_DIR                   /Users/pwinward/projects/myProject/cocos2d/cocos/platform/android/java/libs/
     ANDROID_MANIFEST                   /Users/pwinward/projects/myProject/proj.android/AndroidManifest.xml
     ANDROID_MK                         /Users/pwinward/projects/myProject/proj.android/jni/Android.mk
     ANDROID_MK_USES_WILDCARDS          False
     ANDROID_PROJECT_DIR                /Users/pwinward/projects/myProject/proj.android/
     ANDROID_PROPERTIES                 /Users/pwinward/projects/myProject/proj.android/project.properties
     ANDROID_SDK_DIR                    n/a
     ANDROID_STUDIO_ACTIVITY_NAME       AppActivity
     ANDROID_STUDIO_ACTIVITY_PATH       /Users/pwinward/projects/myProject/proj.android-studio/app/src/org/cocos2dx/cpp/
     ANDROID_STUDIO_JNI_DIR             /Users/pwinward/projects/myProject/proj.android-studio/app/jni/
     ANDROID_STUDIO_LIBS_DIR            /Users/pwinward/projects/myProject/cocos2d/cocos/platform/android/libcocos2dx/libs/
     ANDROID_STUDIO_MANIFEST            /Users/pwinward/projects/myProject/proj.android-studio/app/AndroidManifest.xml
     ANDROID_STUDIO_MK                  /Users/pwinward/projects/myProject/proj.android-studio/app/jni/Android.mk
     ANDROID_STUDIO_MK_USES_WILDCARDS   False
     ANDROID_STUDIO_PROJECT_DIR         /Users/pwinward/projects/myProject/proj.android-studio/
     ANDROID_STUDIO_PROPERTIES          /Users/pwinward/projects/myProject/proj.android-studio/app/project.properties
     APPLICATION_MK                     /Users/pwinward/projects/myProject/proj.android/jni/Application.mk
     COCOS_2DX_INSTALLATION_VERSION     3.8.0
     COCOS_2DX_ROOT                     /Users/pwinward/Downloads/cocos2d-x-3.9/
     COCOS_2DX_VERSION                  3.8.0
     COCOS_BACKUP_DIR                   /Users/pwinward/projects/myProject/backup-2016-02-12/
     COCOS_CLASSES_DIR                  /Users/pwinward/projects/myProject/Classes/
     COCOS_ENGINE_TYPE                  unknown
     COCOS_PROJECT_DIR                  /Users/pwinward/projects/myProject/
     COCOS_PROJECT_HINT                 /Users/pwinward/projects/myProject/
     COCOS_PROJECT_TYPE                 js
     COCOS_RESOURCES_DIR                /Users/pwinward/projects/myProject/res/
     IOS_PROJECT_DIR                    /Users/pwinward/projects/myProject/proj.ios_mac/
     SDKBOX_DIR                         /Users/pwinward/.sdkbox/
     XCODE_PROJECT                      /Users/pwinward/projects/myProject/proj.ios_mac/myProject.xcodeproj/project.pbxproj
     XCODE_PROJECT_CXX_LIBRARY          libc++
     XCODE_PROJECT_DIR                  /Users/pwinward/projects/myProject/proj.ios_mac/myProject.xcodeproj/
     XCODE_PROJECT_PREPROCESSOR

thanks, I’ll let you know what I find.