Interesting Android Crash - Not crash on Win32

All seems fine. I can narrow issues to a exact line of code

Game Object Class

----------Game Object H----------------

#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H

#include "cocos2d.h"
#include <string>

class GameObject
{
	public:

		GameObject(std::string filename, std::string tag, std::string type, cocos2d::Vec2 position, cocos2d::Vec2 anchor, int serial);
		~GameObject();

		cocos2d::Sprite* getSprite();

	private:

		int m_Serial;
		std::string m_Tag;
		std::string m_Type;

		cocos2d::Vec2 m_Position;
		cocos2d::Vec2 m_Target;

		cocos2d::Sprite* m_Sprite;

};
#endif // DEFINE - GAMEOBJECT_H

-----Game Object CPP--------------------------------------------------------------

#include "GameObject.h"

GameObject::GameObject(std::string filename, std::string tag, std::string type, cocos2d::Vec2 position, cocos2d::Vec2 anchor, int serial) {
	m_Sprite = cocos2d::Sprite::create(filename);
	m_Tag = tag;
	m_Type = type;
	m_Sprite->setPosition(position);
	m_Sprite->setAnchorPoint(anchor);
	m_Serial = serial;
	m_Target = cocos2d::Vec2(0, 0);
}

GameObject::~GameObject(){

}

cocos2d::Sprite * GameObject::getSprite(){
	return m_Sprite;
}

--------------------------------GUI H------------------------------------------------------

I call it in GUI Class

#ifndef GUILAYER_H
#define GUILAYER_H

#include "cocos2d.h"
#include "GameObject.h"
#include <string>

class GuiLayer
{
	public:

		GuiLayer(cocos2d::Size windowSize);
		~GuiLayer();

	private:

		cocos2d::Size m_WindowSize;

		GameObject* m_Bottom;

};
#endif // DEFINE - GUILAYER_H

------------------------------GUI CPP----------------------------------------

This is where it crashed on android but works fine on win32

GuiLayer::GuiLayer(cocos2d::Size windowSize) {
	m_WindowSize = windowSize;
	m_Bottom = new GameObject("HUD/UI/bottom.png", "Bottom", "UI", cocos2d::Vec2(0, 0), //HERE cocos2d::Vec2(0, 0), 0);

}

Test Scene CPP

void TestScene::drawHUD(){

	m_HUD = new GuiLayer(m_VisableSize);

	GameObject* m_Bottom = new GameObject("hud/ui/bottom.png", "Bottom", "UI", cocos2d::Vec2(0, 0), cocos2d::Vec2(0, 0), 0);//NO PROBLEM HERE
	m_Bottom->getSprite()->setPosition(cocos2d::Vec2(500,0));
	m_HUDLayer->addChild(m_Bottom->getSprite());

	for (auto graphic : m_HUD->returnGraphics()) { // I THINK ISSUE WITH THIS 
		CCLOG("ONE");
		//m_HUDLayer->addChild(graphic->getSprite(), 0); 
	}

}

If i remove that line to construct new Game Object all works fine. it works fine with the game object on Win32. it builds fine and APP opens for a couple seconds and closes. On windows i can view sprite and all is fine

i tried cleaning project and swapping things around so as use init() instead, cant spot issue

It has to be something I never seen before because this all looks perfect to me.

Hi.
DON’T USE CAPITAL LETTERS IN “SOME STRING”!!!

In windows no difference between capital and small letters but in android it is not.
your folder name may be consist of small letters.

OK great. So can you tell me a little more.

What about naming classes with a capital letter . Is this correct ?

Do you think the issue might be “HUD/UI/bottom.png” ?

Should I name folders all small block ? What about “Resource” ? That is capital naturally

Also “m_MemberName” -> Is this issue too ?

How about "HUD\/UI\/bottom.png"
Let me know.

Just strings. If your folder or image name not equal with strings in your code windows ignore this but you have an error in android build.

So keep folder and file names small block only ? Right ?

I added little part to bottom of question as traced issue back to this function iterator

I’m using range C++11 from this post for iterator. Ill try other ways now

Ok I think I figured out issue. And i didnt present the probelm origionally in this question. I left out a fucntion that was taking part in all this and turns out that was issue.

	for (auto graphic : m_HUD->returnGraphics()) 
		m_HUDLayer->addChild(graphic->getSprite(), 0); 

This is issue. This works usually but it causes android to crash as it doesn’t support its syntax. Once i replaced it for this below, all was ok

	for (auto graphic : m_HUD->returnGraphics()) {
		m_HUDLayer->addChild(graphic->getSprite(), 0); 
	}

Thanks and sorry for wasting time