Eclipse, AndEngine and HelloWorld!!!

  ... tutorials on how to use AndEngine.

Re: Eclipse, AndEngine and HelloWorld!!!

Postby oldskool73 » Tue Dec 07, 2010 9:15 pm

the @override issue is because you have your java compliance level set to 1.5, go project->properties->java compiler and set the compliance level to 1.6, clean the project and the errors should go away.
oldskool73
 
Posts: 128
Joined: Tue Oct 12, 2010 4:04 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby oldskool73 » Tue Dec 07, 2010 9:23 pm

just looking at you timer the logic seems wrong, you're setting the variable in the function params and this wont return the handler that way, I think you want to be doing something like...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. /**
  3.     * Creates a Timer Handler used to Spawn Sprites
  4.     */
  5.    private void createSpriteSpawnTimeHandler()
  6.    {
  7.       TimerHandler spriteTimerHandler = new TimerHandler(200, new ITimerCallback()
  8.       {        
  9.          
  10.           public void onTimePassed(final TimerHandler pTimerHandler)
  11.           {
  12.             spriteTimerHandler.reset();
  13.             //or just pTimerHandler.reset();
  14.            
  15.             //Random Position Generator
  16.             final float xPos = MathUtils.random(30.0f, (CAMERA_WIDTH - 30.0f));
  17.             final float yPos = MathUtils.random(30.0f, (CAMERA_HEIGHT - 30.0f));
  18.            
  19.             createSprite(xPos, yPos);
  20.           }
  21.       })
  22.      
  23.       this.getEngine().registerUpdateHandler(spriteTimerHandler);
  24.    }
  25.  
  26.  
Parsed in 0.017 seconds, using GeSHi 1.0.8.4


...not sure but that may solve the issue you're asking about.

EDIT : hmm, I see that's actually how the tutorial tells you to do it, so ignore me, still seems odd though :)
oldskool73
 
Posts: 128
Joined: Tue Oct 12, 2010 4:04 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby riacheslav » Wed Dec 08, 2010 11:14 pm

Thanks, oldskool. That got it. On both counts. Much appreciated, thanks for your time!
riacheslav
 
Posts: 7
Joined: Thu Dec 02, 2010 10:47 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby dear_gamemaster » Thu Dec 09, 2010 4:35 am

After writing about the final fix in the previous post, I tried it out and it wouldn't work.. This, however, does.. So - sorry for lousy testing-before-posting and thanks, oldskool! :)
dear_gamemaster
 
Posts: 4
Joined: Tue Dec 07, 2010 2:03 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby poettlr » Wed Jan 05, 2011 2:43 am

Hi :)

i'm quite new to android and tried using your helloWorld tut.

I did everything step by step and imported the Default-Branch.

I tried using the lib with Android 2.2 but i got a force Close so i switched back to Android 1.6 but still .. a force close on my HTC Desire any ideas?
poettlr
 
Posts: 3
Joined: Wed Jan 05, 2011 2:39 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby Br0ken » Wed Jan 05, 2011 3:12 am

What's the exception that caused the forced close? It'll be displayed in Logcat (accessed via the DDMS tool if you have the Android Eclipse plugin).
Br0ken
 
Posts: 265
Joined: Sun Sep 12, 2010 3:57 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby poettlr » Wed Jan 05, 2011 3:20 am

Code: Select all
01-05 02:18:53.057: ERROR/AndroidRuntime(8266): FATAL EXCEPTION: main
01-05 02:18:53.057: ERROR/AndroidRuntime(8266): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{at.ironbyte.andengine.hello/at.ironbyte.andengine.hello.helloWorld}: java.lang.ClassNotFoundException: at.ironbyte.andengine.hello.helloWorld in loader dalvik.system.PathClassLoader[/mnt/asec/at.ironbyte.andengine.hello-1/pkg.apk]
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.os.Looper.loop(Looper.java:123)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.ActivityThread.main(ActivityThread.java:4627)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at java.lang.reflect.Method.invokeNative(Native Method)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at java.lang.reflect.Method.invoke(Method.java:521)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at dalvik.system.NativeStart.main(Native Method)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266): Caused by: java.lang.ClassNotFoundException: at.ironbyte.andengine.hello.helloWorld in loader dalvik.system.PathClassLoader[/mnt/asec/at.ironbyte.andengine.hello-1/pkg.apk]
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
01-05 02:18:53.057: ERROR/AndroidRuntime(8266):     ... 11 more
poettlr
 
Posts: 3
Joined: Wed Jan 05, 2011 2:39 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby Br0ken » Wed Jan 05, 2011 3:22 am

There you go, ClassNotFoundException.

Check your class has been referenced correctly, is the path correct? Is the spelling correct? etc?
Br0ken
 
Posts: 265
Joined: Sun Sep 12, 2010 3:57 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby poettlr » Wed Jan 05, 2011 3:27 am

Problem Solved :)
Eclipse renamed my Class...
but actully why am i getting the error if i do a full recompile?
poettlr
 
Posts: 3
Joined: Wed Jan 05, 2011 2:39 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby Br0ken » Wed Jan 05, 2011 3:42 am

Probably because the name of your class was not the same as the reference to the class in your Manifest file, Eclipse compilation does not check the XML file for class references I think, so it failed when you tried to run it instead of at build time.
Br0ken
 
Posts: 265
Joined: Sun Sep 12, 2010 3:57 pm

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 25 guests