I tried to compile a project with integrated Youtube player from SDKBox for Android (Android Studio, android-26). The project is builded with Cocos Creator 1.8.1. The error 'Jsapi.h not found' occurred. I solved this problem by next actions:
added a line to **/cocos/Android.mk in LOCAL_EXPORT_C_INCLUDES $(LOCAL_PATH)/../external/android/$(TARGET_ARCH_ABI)/include/spidermonkey.
Then error occures about ambiguous of RefPtr class. There’s such class from Mozilla (spidermonkey) which conflcts with RefPtr from Cocos2d-x. I had to refactor class RefPtr(Cocos) to CCRefPtr since files no exist refering to that class.
-fpermissive compile key is appended in **/proj.android-studio/app/jni/Application.mk file.
file PluginYoutubeJSHelper.h is modified by changing function prototype void register_all_PluginYoutubeJS_helper(JSContext* cx, JS::HandleObject global);
to bool register_all_PluginYoutubeJS_helper(se::Object* obj);
and added #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" at the top of the file.
Certainly these are not the best actions to fix the error. Please, write what I could to do to workaround this problem more correct.
i updated my cocos from 1.6.1 to 1.8.1, i got an error to delete build file and rebuild, after i did that i injects all the sdkbox plugins i had from before. when i compiled i got this error in log. i tried using both binary and default, same error
[armeabi] Compile++ arm : cocos2djs_shared <= jsb_module_register.cpp
[armeabi] Compile++ arm : cocos2djs_shared <= PluginSdkboxPlayJS.cpp
In file included from C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/jni/…/…/…/Classes/AppDelegate.cpp:32:0:
C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/jni/…/…/…/Classes/PluginYoutubeJSHelper.h:4:19: fatal error: jsapi.h: No such file or directory #include “jsapi.h”
^
compilation terminated.
make: *** [C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi/objs/cocos2djs_shared///__/Classes/AppDelegate.o] Error 1
make: *** Waiting for unfinished jobs…
:WhatYuhKnow:externalNativeBuildRelease FAILED
:WhatYuhKnow:externalNativeBuildRelease (Thread[Task worker for ‘:’,5,main]) completed. Took 14.337 secs.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:WhatYuhKnow:externalNativeBuildRelease’.
Build command failed.
Error while executing process C:\Users\Freshprince\Desktop\adt-bundle-windows-x86_64-20140321\sdk\ndk-bundle\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\Freshprince\Desktop\Coco2dxProject\testCocos\build\jsb-binary\frameworks\runtime-src\proj.android-studio\app\jni\Android.mk NDK_APPLICATION_MK=C:\Users\Freshprince\Desktop\Coco2dxProject\testCocos\build\jsb-binary\frameworks\runtime-src\proj.android-studio\app\jni\Application.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=0 APP_PLATFORM=android-16 NDK_OUT=C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=C:\Users\Freshprince\Desktop\Coco2dxProject\testCocos\build\jsb-binary\frameworks\runtime-src\proj.android-studio\app\build\intermediates\ndkBuild\release\lib NDK_TOOLCHAIN_VERSION=4.9 APP_PLATFORM=android-27 NDK_MODULE_PATH=C:\CocosCreator\resources\cocos2d-x;C:\CocosCreator\resources\cocos2d-x\cocos;C:\CocosCreator\resources\cocos2d-x\external -j4 NDK_DEBUG=0 C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi/libcocos2djs.so}
C:/Users/Freshprince/Desktop/adt-bundle-windows-x86_64-20140321/sdk/ndk-bundle/build//…/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): armeabi
C:/Users/Freshprince/Desktop/adt-bundle-windows-x86_64-20140321/sdk/ndk-bundle/build//…/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed in a future NDK release.
[armeabi] Compile++ arm : cocos2djs_shared <= main.cpp
[armeabi] Compile++ arm : cocos2djs_shared <= AppDelegate.cpp
[armeabi] Compile++ arm : cocos2djs_shared <= jsb_module_register.cpp
[armeabi] Compile++ arm : cocos2djs_shared <= PluginSdkboxPlayJS.cpp
In file included from C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/jni/…/…/…/Classes/AppDelegate.cpp:32:0:
C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/jni/…/…/…/Classes/PluginYoutubeJSHelper.h:4:19: fatal error: jsapi.h: No such file or directory #include “jsapi.h”
^
compilation terminated.
make: *** [C:/Users/Freshprince/Desktop/Coco2dxProject/testCocos/build/jsb-binary/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi/objs/cocos2djs_shared///__/Classes/AppDelegate.o] Error 1
make: *** Waiting for unfinished jobs…
Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
OK. I checked the PluginYoutubeJSHelper.h, it’s not correct.
plz update the PluginYoutubeJSHelper.h with bellow code:
#pragma once
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
#include "scripting/js-bindings/manual/jsb_conversions.hpp"
namespace se {
class Object;
}
bool register_all_PluginYoutubeJS_helper(se::Object* obj);