Hi!
I’m trying to add JNI to my project but I’m getting linker error:
Error 1 error LNK2019: unresolved external symbol "__declspec(dllimport) public: static bool __cdecl cocos2d::JniHelper::getStaticMethodInfo(struct cocos2d::JniMethodInfo_ &,char const *,char const *,char const *)" (__imp_?getStaticMethodInfo@JniHelper@cocos2d@@SA_NAAUJniMethodInfo_@2@PBD11@Z) referenced in function _callEndGame AndroidJNI_EndGameDelegate.obj Proj.win32
Inside libcocos2d.lib there is no such a function because cocos2d-win32.vc2012.sln project didn’t compile cocos2d-x-2.2.4\cocos2dx\platform\android folder.
How can I resolve it?
Thank you.
Why there is dllimport?
JNIHelper is only used for Android.
I have the following structure in my project:
- Utils class that has EndGame method. I used to call it instead of Director->end() because I need to know when the application is finished. EndGame method calls Java method from my Android activity. (here I have a problem)
Also I have CloseApp method with Director->end() call. This method is called from Android activity. (this part is not et implemented)
- Inside Android part of project I have method for EndGame and after I finish all the things I call C++ ClosedApp.
In C++ Utils.EndGame I’m using JNI but I have compilation problems.
I understood the structure.
What i wonder is that you used VS to develop and build Android application?
Problem solved!
It appears because I tried to compile my project from VS.
But when I use native_build.sh compilation was done without errors.