Libgdx + Box2d = ~8 fps on android?

Heyho folks ^^

I was wondering about my performance on an android.
Just to test i made a very simple “Game” where i just make a world (box2d) + renderer and cam.
I have added 1 Body with this code:


BodyDef circleDef = new BodyDef();
		circleDef.type = BodyType.DynamicBody;
		circleDef.position.set(80, 120);
		
		Body circleBody = world.createBody(circleDef);
		
		CircleShape cs = new CircleShape();
		cs.setRadius(1);
		
		FixtureDef fd = new FixtureDef();
		fd.shape = cs;
		fd.density = 1;
		fd.friction = 0.2f;
		fd.restitution = 0.8f;
		
		circleBody.createFixture(fd);
		return circleBody;

here is my rendering method :


public void update(float delta)
	{
		renderer.render(world, cam.combined);
		world.step(1/60f, 6, 2);
	}

now on my comp i have got like 60 fps thats okay but after launching on android it drops to ~8 fps o.O and this is not suitable for me =(

its the first time im working with android and my second time working with libgdx.

My question is:
can i somehow get this running on android or should i just forget it? (btw. i cant connect a real android atm so i use the AVD for Nexus One made out of the given Device Definitions)

The emulator is crap, even if you enable hardware support for the graphics. Real world performance is usually much better. If you have an APK of your app, just upload it and i can give it a try on some real devices if that helps.

hey thanks =) then ill test it out on desktop version until i got a phone :stuck_out_tongue:

I can completely agree with the above comment about the emulator performance.
I’m honestly surprised you managed to get around 8FPS out of it!

My Advice
Buy a cheap Chinese Android tablet/phone from Amazon. I’d highly recommend that, because then you get used to developing on lower-end hardware. So you can focus more on optimizing your code.

Why a cheap one?
I got so used to coding on quad core phones and tablets, that my players where complaining about performance on their lower end devices. So I had to completely re-think my development cycle; and do what I said above.

If you share your APK, I can test it for you, to make sure its just the emulator issue. If you want, that is

Though this is more of a 1 time test, to see if thats in. Not really a long term development solution

Just a side-note: The Box2DRenderer is also much slower than rendering sprites as Bodies.

thanks for the advices ^^ at the moment it is not necessary to check the code it was just a test if i could work with box2d
but atm i am working on my first game maybe ill get it to WIP soon ^^