0
votes

all.

I added my picture "Icon2222.png" into my project, and changed the name of picture from "grossini.png"(which is original) to "Icon2222.png",

but when I run the project, it crashed with the exception named NSInternalInconsistencyException and hint me that "Can't create Texture. UIImage is nil".

Where did I make a mistake? I just replaced a picture.

Thanks in advance.

2012-05-03 14:59:10.480 ActionManagerTest[3215:f803] cocos2d: cocos2d v1.0.1

2012-05-03 14:59:10.481 ActionManagerTest[3215:f803] cocos2d: Using Director Type:CCDirectorDisplayLink

2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: OS version: 5.0 (0x05000000)

2012-05-03 14:59:10.529 ActionManagerTest[3215:f803] cocos2d: GL_VENDOR: Apple Computer, Inc.

2012-05-03 14:59:10.530 ActionManagerTest[3215:f803] cocos2d: GL_RENDERER: Apple Software Renderer

2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 APPLE

2012-05-03 14:59:10.531 ActionManagerTest[3215:f803] cocos2d: GL_MAX_TEXTURE_SIZE: 4096

2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16

2012-05-03 14:59:10.532 ActionManagerTest[3215:f803] cocos2d: GL_MAX_SAMPLES: 4

2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL supports PVRTC: YES

2012-05-03 14:59:10.533 ActionManagerTest[3215:f803] cocos2d: GL supports BGRA8888 textures: YES

2012-05-03 14:59:10.534 ActionManagerTest[3215:f803] cocos2d: GL supports NPOT textures: YES

2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: GL supports discard_framebuffer: YES

2012-05-03 14:59:10.535 ActionManagerTest[3215:f803] cocos2d: compiled with NPOT support: NO

2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d: compiled with VBO support in TextureAtlas : YES

2012-05-03 14:59:10.536 ActionManagerTest[3215:f803] cocos2d: compiled with Affine Matrix transformation in CCNode : YES

2012-05-03 14:59:10.537 ActionManagerTest[3215:f803] cocos2d: compiled with Profiling Support: NO

2012-05-03 14:59:10.549 ActionManagerTest[3215:f803] Retina Display Not supported

2012-05-03 14:59:10.550 ActionManagerTest[3215:f803] cocos2d: CCTexture2D. Can't create Texture. UIImage is nil

2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: deallocing [Switching to process 3215 thread 0x12f0b]

2012-05-03 14:59:10.551 ActionManagerTest[3215:f803] cocos2d: Couldn't add image:Icon2222.png in CCTextureCache

2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] cocos2d: deallocing

2012-05-03 14:59:10.559 ActionManagerTest[3215:f803] * Assertion failure in -[CCLayer addChild:], /Users/qusean/Downloads/cocos2d-iphone-1.0.1/cocos2d/CCNode.m:413

2012-05-03 14:59:10.561 ActionManagerTest[3215:f803] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'

* First throw call stack: (0x17de052 0x14ddd0a 0x1786a78 0x1e92db 0xb300 0x4546 0x4adb0e 0x4ae8a6 0x4bd743 0x4be1f8 0x4b1aa9 0x1ed4fa9 0x17b21c5 0x1717022 0x171590a 0x1714db4 0x1714ccb 0x4ae2a7 0x4afa9b 0x2581 0x2505 0x1) terminate called throwing an exception

Here is my code:

1

CCSprite *child = [CCSprite spriteWithFile:@"Icon2222.png"];    
[child setPosition:ccp(200,200)];
[layer addChild:child];

2

CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite *player = [CCSprite spriteWithFile:@"Icon2222.png"
                                               rect:CGRectMake(0, 0, 27, 40)];
player.position = ccp(player.contentSize.width/2, winSize.height/2);
[layer addChild:player];

Both of them crashed.

4
Don't make assumptions, read the console log. It's a different image that wasn't found. Hint: it starts with "Icon". - LearnCocos2D
I used another image to try again, but still failed, that's why the names are different, "image1.png"and"Icon2222.png", but neither of them works. - Sean

4 Answers

1
votes

I met the problem before.

The same happened Cause i changed the png name in the finder many times.

Use the original output png name which created by your Graphic tools will be smooth going.

wish it will be helpful

0
votes

Delete the file from the bundle, then bring it back in with the correct file name. You are only changing the name of the file within the local project, not within the project directory.

0
votes

I suggest you to clean the build... Delete the app.. And run again... In case it doesn't solve your problem... Remove all resources and add again to project... Hope this helps.. :)

0
votes

I know this thread is rather old, but i ran into same problem and my solution might help future lost souls.

My problem was that the file was not attached to the target and hence was not included and could not be found.

I.e. remember to make sure that the file is checked to be in your target in the Utility tab, or when you import the file.
enter image description here