project transplant to android use java call c++ via jni,there is no label in screen,why?

java code:

Cocos2d-xRenderer.java

public void onDrawFrame(final GL10 gl){
…….

Cocos2dxRenderer.nativeRender();
Cocos2dxRenderer.nativeAddLabel();
…….
}

private static native void nativeAddLabel();

/////

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeAddLabel(JNIEnv* env, jobject thiz)
{
HelloWorld::Instance()>addLabel;
}
//HelloWorldScene.cpp
void HelloWorld::addLabel{
CCLog;
CCSize size=CCDirector::sharedDirector
>getWinSize;
CCLabelTTF* Testlabel=CCLabelTTF::create;
Testlabel~~>setColor);
Testlabel~~>setPosition(ccp(size.width/2,size.height/4*3));

CCLog(“label position:————%2.1f”,Testlabel~~>getPosition.x);
this~~>addChild(Testlabel,2);

}

so,I run this,I can get the “java call c++ success” message,but this is no CCLabelTTF in my android screen, why i can’t get the right result……please help !

I came across this problem as well. For me the problem was that I didn’t send the java call across the OpenGL thread. So that I received the java call on a thread that knows no OpenGL context and therefor can’t draw the text.

The solution is to call your method on the OpenGL Thread in Java.

    this.runOnGLThread(
        new Runnable() {
            public void run() {
                nativeAddLabel();
            }
        }
    );