[英]Android, native app can't start when I use std::vector::push_back()
I need to use the vector container in my native application (it's cocos-2dx framework) So, I've added 我需要在本机应用程序(它是cocos-2dx框架)中使用向量容器,因此,我添加了
APP_STL := stlport_static APP_STL:= stlport_static
to Application.mk
Then 然后到Application.mk
#include <vector>
in header file for the class which uses vector Define the variable as 在使用vector的类的头文件中,将变量定义为
std::vector<cocos2d::CCPoint*> *m_VertexAnchors;
And then do this 然后做
m_VertexAnchors->push_back(point);
point
here is actually CCPoint* point
And when I run my app I just see the black screen than it disappears after 2-3 sec without any message. point
这里实际上是CCPoint* point
当我跑我的应用我只是看到黑色的屏幕比有2-3秒后消失,没有任何消息。 The last message in logcat is (filter by application name and with verbose level) logcat中的最后一条消息是(按应用程序名称和详细级别过滤)
04-01 13:22:57.068: D/dalvikvm(2939): GC_EXTERNAL_ALLOC freed 64K, 47% free 2887K/5379K, external 0K/0K, paused 40ms 04-01 13:22:57.068:D / dalvikvm(2939):GC_EXTERNAL_ALLOC释放64K,47%释放2887K / 5379K,外部0K / 0K,暂停40ms
and there are no errors before just messages about loading libs. 并且仅在有关加载库的消息之前没有错误。 And I've not seen anything strange in the main log. 而且我没有在主日志中看到任何奇怪的东西。 Then when I commented out 然后当我注释掉
m_VertexAnchors->push_back(point);
the app works fine. 该应用程序运行正常。
So, is there anything I've missed, if no how could I debug this (I use Eclipse with sequoyah plugin) 所以,有什么我想念的,如果没有的话,我该如何调试(我将Eclipse与sequoyah插件一起使用)
Will appreciate any help or suggestions, thanks. 将不胜感激任何帮助或建议,谢谢。
Before using m_vertexAnchors
you must initialize it correctly: 在使用m_vertexAnchors
之前,您必须正确地初始化它:
m_VertexAnchors = new std::vector<cocos2d::CCPoint*>();
you must remember to delete
it when no longer required. 您必须记住在不再需要时delete
其delete
。
If you can avoid dynamically allocating the vector
then declare it as: 如果可以避免动态分配vector
则将其声明为:
std::vector<cocos2d::CCPoint*> m_VertexAnchors;
and use it: 并使用它:
m_VertexAnchors.push_back(point);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.