Trying To Use Cocos Creator Scene and Button Gives Fatal Error

Cocos2dx 3.16
Android Studio 3.0

Hello, I Used the creator_to_cocos2dx to add a scene in code.

Scene* MScene::createScene()
{
creator::CreatorReader* reader = creator::CreatorReader::createWithFilename(“creator/MScene.ccreator”);

// will create the needed spritesheets + design resolution
reader->setup();

// get the scene graph
Scene * MScene = reader->getSceneGraph();

// ...and use it
Director::getInstance()->replaceScene(MScene);


auto FSSelect = ( ui::Button * )MScene->getChildByName("FSSelect" );

FSSelect->addTouchEventListener([&](Ref* sender, Widget::TouchEventType type){
    switch (type)
    {
        case ui::Widget::TouchEventType::BEGAN:
            break;
        case ui::Widget::TouchEventType::ENDED:
            Director::getInstance()->end();
            break;
        default:
            break;
    }
});

// return the scene
return MScene;
}

The Code Works Fine and I’m just trying to familiarise myself more with how everything works, after the FSSelect->addTouchEventListener([&](Ref* sender, Widget::TouchEventType type) portion was added my app would crash on launch i opened logcat to see if i could make sense of anything.

i get this error right before crash

A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x2c0 in tid 18965 (GLThread 21123)

I have looked and cannot find much info on this could anyone offer me guidance?

Seems to me like FSSelect is null, check if you are getting it successfully before adding an event listener. Maybe FSSelect is in another Node that’s on the Scene and not a direct child of MScene?

How would i go about this?