HelloWorld 出sigsegv错误

auto label = Label::createWithTTF(“Hello World”, “fonts/Marker Felt.ttf”, 24);

label->setPosition(100, 100);

setPosition 出sigsegv错误,我猜测是字体没被打包进去,然后我把Resources目录拷贝到asset下,还是报错。

我是现在用命令行python脚本建立项目,然后在adt里面import的proj.android,然后调试就报错。

环境:windows10,android-ndk-r10,cocos2d-x 3.11.1,adt

需要怎么操作?
完整代码:

#include “HelloWorldScene.h”
#include “SimpleAudioEngine.h”

USING_NS_CC;

Scene* HelloWorld::createScene()
{
// ‘scene’ is an autorelease object
auto scene = Scene::create();

// 'layer' is an autorelease object
auto layer = HelloWorld::create();

// add layer as a child to scene
scene->addChild(layer);

// return the scene
return scene;

}

void CCLogError(const char * pszFormat, …)
{
va_list args;
va_start(args, pszFormat);
va_end(args);
__android_log_print(ANDROID_LOG_ERROR, “cocos2d-x debug info”, pszFormat, args);
}

// on “init” you need to initialize your instance
bool HelloWorld::init()
{
CCLogError(“init 0”);
if ( !Layer::init() )
{
return false;
}

auto visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();

CCLogError("init 1\norigin.x= %ld, \nvisibleSize.width=%f", origin.x, visibleSize.width);



CCLogError("==========================1=============================A");
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
CCLogError("==========================2=============================");
label->setPosition(100, 100);
CCLogError("==========================3=============================");
this->addChild(label, 1);
CCLogError("==========================4=============================");


return true;

}

void HelloWorld::menuCloseCallback(Ref* pSender)
{
Director::getInstance()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}

windows10下,vs2015 这个proj.win32能打开,然后编译运行。

就是adt导入的不行!

能否把从创建到打包生成apk的过程说得详细一些?

cocos命令会自动做这个事情,而且会打包到APK里。你如果要确认资源是否存在可以把.apk改成.zip,然后解压出来看看里面的内容。

谢谢,

操作步骤:
1、打开cmd,执行:python cocos.py new HelloWorldCpp -p com.coco2dx.org -l cpp -d D:\cocos2dProjects
2、打开adt,选择file-> import -> android -> Existing Android code into workspace,选择D:\cocos2dProjects\HelloWorld
3、adt,右键点击HelloWorld项目->debug as->Android application

经过加入log,发现是在label->setPosition(100, 100);这行出错。

@lein_urg163.com 你是通过Eclipse配置编译c++代码并打包的?确认字体被达到apk里了吗?