from jni reterned jstring cast to string and send cocos class.
CCLabelTTF::setString() as an argument to put string.c_str() and casting to char type.
build a success normally (without error), but the android runtime error occurs.
I do not know what the problem is cause.
Please help me!
Thank you.
Which version of cocos2d-x you are using?
Could you provide more informations about how to reproduce this issue?
A demo will be better.
James Chen wrote:
Which version of cocos2d-x you are using?
Could you provide more informations about how to reproduce this issue?
A demo will be better.
version 2.0.4 and demo make as soon as possile
this error solution is necessary to smartfoxserver api using android
James Chen wrote:
Which version of cocos2d-x you are using?
Could you provide more informations about how to reproduce this issue?
A demo will be better.
cpp header
byeongseok yu wrote:
James Chen wrote:
> Which version of cocos2d-x you are using?
> Could you provide more informations about how to reproduce this issue?
> A demo will be better.
>
cpp header
cpp
byeongseok yu wrote:
byeongseok yu wrote:
> James Chen wrote:
> > Which version of cocos2d-x you are using?
> > Could you provide more informations about how to reproduce this issue?
> > A demo will be better.
>
> cpp header
>
cpp
java
Why did you use HelloWorldLayer like this?
#ifdef __cplusplus
8
extern "C" {
9
#endif
10
JNIEXPORT void JNICALL Java_com_demo_jniCCLabelTTF_nativeCall(JNIEnv *env, jobject thiz, jstring msg)
11
{
12
CCLog("nativeCall");
13
std::string str;
14
char* cMsg = strdup((*env).GetStringUTFChars(msg, 0));
15
HelloWorld hello; // You allocated HelloworldLayer on stack. No crashes will be strange. -_-!!!
16
hello.changString(cMsg);
17
18
env->ReleaseStringUTFChars(msg, cMsg);
19
free(cMsg);
20
}
21
#ifdef __cplusplus
22
}
23
#endif