RC1 JNI call C++ error

hello.
in ver RC1,
i try call c++ function from Java.

but it is error,
java.lang.UnsatisfiedLinkError: Native method not found: org.cocos2dx.cpp.AppActivity.CppFunc:()V
pease help this problem.

AppActivity.java

package org.cocos2dx.cpp;
import org.cocos2dx.lib.Cocos2dxActivity;
public class AppActivity extends Cocos2dxActivity
{
    public static native void CppFunc();
}

hellowolrd.cpp

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    #include "platform/android/jni/JniHelper.h"
#endif

extern "C" {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    JNIEXPORT void JNICALL  Java_org_cocos2dx_cpp_AppActivity_CppFunc(JNIEnv *env, jobject obj)
    {
       
    }
#endif

I think your method signature is incorrect.
It’s declared as having no parameter but implemented as having 1 parameter.

Try it like this:

JNIEXPORT void JNICALL  Java_org_cocos2dx_cpp_AppActivity_CppFunc(JNIEnv *env)
{
...
}

devnoob
thanks for help
its not work. :frowning:

Are you missing a curly closing bracket?

extern "C" {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    JNIEXPORT void JNICALL  Java_org_cocos2dx_cpp_AppActivity_CppFunc(JNIEnv *env)
    {
     ...
    }
#endif
}

its not work. :frowning:
i think RC1 is different pre ver.

Did you add helloworld.cpp in the proj.android/jni/Android.mk file?

lance_gray
Yes. everything is fine.
i can’t call c++ in RC1 ver.

@jamesYou Have you succeeded in calling C++ from java? I have the same issue.

UPDATE:
Solution found. Just in case somebody will have same problem.
I have named the methods in this way

void Java_org_cocos2dx_cpp_AppActivity_methodName

also, in a .h file I have put the method in extern “C” in the file of the class, but outside of the class declaration:

extern "C"
{
    void Java_org_cocos2dx_cpp_AppActivity_methodName(JNIEnv* env, jobject thiz);
};

and in .cpp file just like this:

using namespace cocos2d;

void Java_org_cocos2dx_cpp_AppActivity_methodName(JNIEnv * env, jobject thiz)
{
	CCLOG("Called C++ method!");
}