Narendrabrsoft / cocos2d-android-1

Automatically exported from code.google.com/p/cocos2d-android-1
0 stars 0 forks source link

Crashed when creating a CCSprite #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi I try to create a CCSprite like this:

CCSprite aSprite = CCSprite.sprite("bird.png");
addChild(aSprite, 1);
aSprite.setPosition(CGPoint.make(60, s.height / 3));

It crashed when run in simulator, samething happend when i create a Sprite 
Sheet. The bird.png is in the assets folder.

My environment, is Win 7, eclipse with the latest cocos2d-android build.

I got the null pointer exception:

12-15 10:38:52.904: ERROR/AndroidRuntime(253): Uncaught handler: thread main 
exiting due to uncaught exception
12-15 10:38:53.054: ERROR/AndroidRuntime(253): java.lang.RuntimeException: 
Unable to start activity 
ComponentInfo{com.cfandroid.helloandroid/com.cfandroid.helloandroid.HelloAndroid
}: java.lang.NullPointerException
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.ActivityThread.access$2100(ActivityThread.java:116)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.os.Looper.loop(Looper.java:123)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.ActivityThread.main(ActivityThread.java:4203)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
java.lang.reflect.Method.invokeNative(Native Method)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
java.lang.reflect.Method.invoke(Method.java:521)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
dalvik.system.NativeStart.main(Native Method)
12-15 10:38:53.054: ERROR/AndroidRuntime(253): Caused by: 
java.lang.NullPointerException
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
org.cocos2d.opengl.CCTexture2D.<init>(CCTexture2D.java:138)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
org.cocos2d.nodes.CCTextureCache.createTextureFromBitmap(CCTextureCache.java:150
)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
org.cocos2d.nodes.CCTextureCache.createTextureFromFilePath(CCTextureCache.java:1
42)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
org.cocos2d.nodes.CCTextureCache.addImage(CCTextureCache.java:61)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
org.cocos2d.nodes.CCSprite.<init>(CCSprite.java:342)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
org.cocos2d.nodes.CCSprite.sprite(CCSprite.java:251)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
com.cfandroid.helloandroid.HelloAndroid$HelloWorldLayer.<init>(HelloAndroid.java
:101)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
com.cfandroid.helloandroid.HelloAndroid$HelloWorldLayer.scene(HelloAndroid.java:
86)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
com.cfandroid.helloandroid.HelloAndroid.onStart(HelloAndroid.java:53)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1205)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.Activity.performStart(Activity.java:3520)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2373)
12-15 10:38:53.054: ERROR/AndroidRuntime(253):     ... 11 more

Original issue reported on code.google.com by ch33fo...@gmail.com on 15 Dec 2010 at 10:39

GoogleCodeExporter commented 8 years ago
This doesn't look like the latest build.

Original comment by opengen...@gmail.com on 15 Dec 2010 at 11:04

GoogleCodeExporter commented 8 years ago
hmm... could you tell me where can i get the latest build? The one I use I 
downloaded it from 
http://code.google.com/p/cocos2d-android-1/downloads/list/cocos2d-android.jar

I have also use the one from the template but it is the same.

Original comment by ch33fo...@gmail.com on 16 Dec 2010 at 5:17

GoogleCodeExporter commented 8 years ago
I don't know how often sources on google are updated, but the latest changes 
are here: http://github.com/ZhouWeikuan/cocos2d

Original comment by opengen...@gmail.com on 16 Dec 2010 at 10:02