Android/Cocos2d-x unsatisfiedlinkerror using JNI using Java to call C++ -


edit: i've solved problem (and found next issue in long line of jni tribulations!) changing following:

delete "static" declaration of native method in both java , c++, add java method instance of simplegame class, , calling

public static void callcppapiresponse (string result, string token, long context) { **getinstance()**.cppandroidapiresponse(token, 200, result, result.length(), context); } 

now information makes java c++. may else similar issue.

original post:

i'm using cocos2d-x platform , writing c++ code cross-platform ios/android app, , there methods need handled respective native ios/android systems, need able call java c++ call c++ java.

i able load shared library app , trigger java response c++, when try call c++ java following logcat output , app crashes:

dalvik vm     no implementation found native lorg/cocos2dx/simplegame/simplegame; cppsideandroidapiresponse:(ljava/lang/string;iljava/lang/string;ij)v androidruntime      java.lang.unsatisfiedlinkerror: native method not found: org.cocos2dx.simplegame.simplegame.cppandroidapiresponse:(ljava/lang/string;iljava/lang/string;ij)v 

here relevant java code:

package org.cocos2dx.simplegame;  private static native void cppandroidapiresponse(string token, int response, string data, int datalen, long context);  static {     system.loadlibrary("sb"); }  public static void callcppapiresponse (string result, string token, long context) { //this error triggered     cppandroidapiresponse(token, 200, result, result.length(), context); } 

and in c++ file cppside.h:

# if (cc_target_platform == cc_platform_android) #include "platform/android/jni/jnihelper.h" #include <jni.h> #endif  #ifdef __cplusplus extern "c" { #endif # if (cc_target_platform == cc_platform_android) jniexport static void jnicall  java_org_cocos2dx_simplegame_simplegame_cppandroidapiresponse(jnienv *, jobject, jstring, jint, jstring, jint, jlong); #endif #ifdef __cplusplus } #endif 

then cppside.cpp file

#include "cppside.h"  extern "c" { jniexport static void jnicall       java_org_cocos2dx_simplegame_simplegame_cppandroidapiresponse(jnienv *env, jobject obj, jstring token, jint response, jstring data, jint length, jlong context) { ...do stuff...} } 

i know shared library loading because c++ based loading screen, , know jni working @ least partially because able call java same cppside.cpp file in method. have been researching jni , cocos2d-x documentation, no avail.

thanks in advance!


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -