Android lag Plus How i made it run !

Ok, i finnaly made my little project to run in Android.
To do that, i created the project with “gdx-setup-ai” and put the code in src package.
made some changes and put the images in the data folder.

It run, but it lags , and a LOT.

05-24 16:26:58.886: I/AndroidInput(2319): sensor listener tear down
05-24 16:26:58.886: I/AndroidGraphics(2319): Managed meshes/app: { }
05-24 16:26:58.896: I/AndroidGraphics(2319): Managed textures/app: { }
05-24 16:26:58.896: I/AndroidGraphics(2319): Managed shaders/app: { }
05-24 16:26:58.896: I/AndroidGraphics(2319): Managed buffers/app: { }
05-24 16:33:50.535: D/dalvikvm(2475): Trying to load lib /data/app-lib/com.me.mygdxgame-2/libgdx.so 0x40cdf388
05-24 16:33:50.535: D/dalvikvm(2475): Added shared lib /data/app-lib/com.me.mygdxgame-2/libgdx.so 0x40cdf388
05-24 16:33:50.535: D/dalvikvm(2475): No JNI_OnLoad found in /data/app-lib/com.me.mygdxgame-2/libgdx.so 0x40cdf388, skipping init
05-24 16:33:50.915: I/AndroidInput(2475): sensor listener setup
05-24 16:33:51.065: D/libEGL(2475): Emulator without GPU support detected. Fallback to software renderer.
05-24 16:33:51.065: D/libEGL(2475): loaded /system/lib/egl/libGLES_android.so
05-24 16:33:51.125: I/Choreographer(2475): Skipped 41 frames!  The application may be doing too much work on its main thread.
05-24 16:33:51.225: D/gralloc_goldfish(2475): Emulator without GPU emulation detected.
05-24 16:33:51.285: I/AndroidGraphics(2475): OGL renderer: Android PixelFlinger 1.4
05-24 16:33:51.285: I/AndroidGraphics(2475): OGL vendor: Android
05-24 16:33:51.285: I/AndroidGraphics(2475): OGL version: OpenGL ES-CM 1.0
05-24 16:33:51.285: I/AndroidGraphics(2475): OGL extensions: GL_EXT_debug_marker GL_OES_byte_coordinates GL_OES_fixed_point GL_OES_single_precision GL_OES_read_format GL_OES_compressed_paletted_texture GL_OES_draw_texture GL_OES_matrix_get GL_OES_query_matrix GL_OES_EGL_image GL_OES_EGL_sync GL_OES_compressed_ETC1_RGB8_texture GL_ARB_texture_compression GL_ARB_texture_non_power_of_two GL_ANDROID_user_clip_plane GL_ANDROID_vertex_buffer_object GL_ANDROID_generate_mipmap 
05-24 16:33:51.285: I/AndroidGraphics(2475): framebuffer: (5, 6, 5, 0)
05-24 16:33:51.295: I/AndroidGraphics(2475): depthbuffer: (16)
05-24 16:33:51.305: I/AndroidGraphics(2475): stencilbuffer: (0)
05-24 16:33:51.305: I/AndroidGraphics(2475): samples: (0)
05-24 16:33:51.305: I/AndroidGraphics(2475): coverage sampling: (false)
05-24 16:33:51.345: I/AndroidGraphics(2475): Managed meshes/app: { }
05-24 16:33:51.345: I/AndroidGraphics(2475): Managed textures/app: { }
05-24 16:33:51.345: I/AndroidGraphics(2475): Managed shaders/app: { }
05-24 16:33:51.345: I/AndroidGraphics(2475): Managed buffers/app: { }
05-24 16:33:51.485: D/dalvikvm(2475): GC_FOR_ALLOC freed 81K, 8% free 2472K/2676K, paused 124ms, total 126ms
05-24 16:33:51.655: I/dalvikvm-heap(2475): Grow heap (frag case) to 6.459MB for 4121403-byte allocation
05-24 16:33:51.705: D/dalvikvm(2475): GC_FOR_ALLOC freed 1K, 4% free 6495K/6704K, paused 59ms, total 59ms
05-24 16:33:52.065: I/Choreographer(2475): Skipped 148 frames!  The application may be doing too much work on its main thread.
05-24 16:33:52.075: D/dalvikvm(2475): GC_CONCURRENT freed <1K, 4% free 6498K/6704K, paused 14ms+120ms, total 332ms
05-24 16:33:56.375: D/dalvikvm(2475): GC_EXPLICIT freed 4064K, 63% free 2557K/6796K, paused 4ms+8ms, total 61ms
05-24 16:33:57.066: D/dalvikvm(2475): GC_CONCURRENT freed 235K, 60% free 2728K/6796K, paused 99ms+115ms, total 325ms
05-24 16:33:57.296: I/System.out(2475): Removing :0
05-24 16:33:57.326: I/ARMAssembler(2475): generated scanline__00000177:03545444_00001003_00000000 [ 94 ipp] (146 ins) at [0x4c70d1f0:0x4c70d438] in 7286177 ns
05-24 16:33:57.345: I/ARMAssembler(2475): generated scanline__00000177:03545444_00001001_00000000 [ 94 ipp] (146 ins) at [0x4c70d440:0x4c70d688] in 977188 ns
05-24 16:34:10.785: I/Choreographer(2475): Skipped 34 frames!  The application may be doing too much work on its main thread.
05-24 16:34:50.076: I/System.out(2475): Missile Removed :: 0
05-24 16:34:54.975: I/System.out(2475): Missile Removed :: 1
05-24 16:34:54.995: I/System.out(2475): Enemy Plane Removed :: 0
05-24 16:34:55.605: I/System.out(2475): Missile Removed :: 1
05-24 16:34:55.605: I/System.out(2475): Enemy Plane Removed :: 0
05-24 16:34:55.695: I/System.out(2475): Missile Removed :: 0
05-24 16:34:55.935: I/System.out(2475): Removing :0
05-24 16:34:56.595: I/System.out(2475): Removing :0
05-24 16:34:56.705: I/System.out(2475): Missile Removed :: 0
05-24 16:34:56.705: I/System.out(2475): Enemy Plane Removed :: 0
05-24 16:34:57.635: I/System.out(2475): Missile Removed :: 0
05-24 16:34:57.635: I/System.out(2475): Enemy Plane Removed :: 0
05-24 16:34:57.886: I/System.out(2475): Removing :0
05-24 16:34:58.555: I/System.out(2475): Missile Removed :: 0
05-24 16:34:58.555: I/System.out(2475): Enemy Plane Removed :: 0
05-24 16:34:58.795: I/System.out(2475): Removing :0
05-24 16:34:59.645: I/System.out(2475): Missile Removed :: 0
05-24 16:34:59.645: I/System.out(2475): Enemy Plane Removed :: 0
05-24 16:34:59.825: I/System.out(2475): Removing :0
05-24 16:35:01.006: I/System.out(2475): Removing :0
05-24 16:35:19.825: I/System.out(2475): Missile Removed :: 0
05-24 16:35:23.966: D/dalvikvm(2475): GC_CONCURRENT freed 364K, 60% free 2748K/6776K, paused 5ms+38ms, total 311ms

Is There Anything that i can do about it ?

I improved the emulator settings and i guess it improved a bit. But, i dont think an android will be able to run with this requirements.

[2013-05-25 22:22:07 - SDK Manager] SD Card already present with same size, was not changed.
[2013-05-25 22:22:07 - SDK Manager] Updated AVD 'wvgaxD' based on Android 4.2.2, ARM (armeabi-v7a) processor,
[2013-05-25 22:22:07 - SDK Manager] with the following hardware config:
[2013-05-25 22:22:07 - SDK Manager] hw.sdCard=yes
[2013-05-25 22:22:07 - SDK Manager] hw.device.manufacturer=Google
[2013-05-25 22:22:07 - SDK Manager] hw.mainKeys=yes
[2013-05-25 22:22:07 - SDK Manager] hw.lcd.density=240
[2013-05-25 22:22:07 - SDK Manager] hw.accelerometer=yes
[2013-05-25 22:22:07 - SDK Manager] hw.dPad=no
[2013-05-25 22:22:07 - SDK Manager] hw.device.hash=-1812631727
[2013-05-25 22:22:07 - SDK Manager] hw.trackBall=yes
[2013-05-25 22:22:07 - SDK Manager] hw.device.name=Nexus One
[2013-05-25 22:22:07 - SDK Manager] hw.camera.back=none
[2013-05-25 22:22:07 - SDK Manager] hw.sensors.proximity=yes
[2013-05-25 22:22:07 - SDK Manager] hw.battery=no
[2013-05-25 22:22:07 - SDK Manager] disk.dataPartition.size=200M
[2013-05-25 22:22:07 - SDK Manager] hw.gpu.enabled=yes
[2013-05-25 22:22:07 - SDK Manager] hw.audioInput=yes
[2013-05-25 22:22:07 - SDK Manager] hw.sensors.orientation=no
[2013-05-25 22:22:07 - SDK Manager] hw.gps=yes
[2013-05-25 22:22:07 - SDK Manager] skin.dynamic=yes
[2013-05-25 22:22:07 - SDK Manager] hw.keyboard=yes
[2013-05-25 22:22:07 - SDK Manager] vm.heapSize=256
[2013-05-25 22:22:07 - SDK Manager] hw.ramSize=512

I have absolutely no experience in dev for Android, but if you’re running the AVD, it’s bound to be laggy, I think.

If you are running on an emulator it will lag and there isn’t much you can do about it. you really need to test it on an android device.

Ah ok.
If i want to use Accelerator to get the touchs on the screen, it says its not supported. What should i do :stuck_out_tongue: ?

You use libgdx? run through desktop project and bet your best it’ll run same on the device.

Ah okay.
Is this correct?

package UserInterface;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;

/**
 *
 * @author André Vinícius Lopes
 */
public class AccelerometerA extends JoystickModel {

    @Override
    public void listener() 
    {
        float accelX = Gdx.input.getAccelerometerX();
        float accelY = Gdx.input.getAccelerometerY();
        float accelZ = Gdx.input.getAccelerometerZ();

        if(accelX > 0)
        {
            moveRight = true;
        }else
            if(accelX < 0)
            {
                moveLeft = true;
            }
        
        if(accelY > 0)
        {
            moveUp = true;
        }else
            if(accelY < 0)
            {
                moveDown = true;
            }
        
        //moveRight = Gdx.input.isKeyPressed(Input.Keys.DPAD_RIGHT);
        //moveLeft = Gdx.input.isKeyPressed(Input.Keys.DPAD_LEFT);

        //Not Used : 
        //moveUp = Gdx.input.isKeyPressed(Input.Keys.DPAD_UP);
        //moveDown = Gdx.input.isKeyPressed(Input.Keys.DPAD_DOWN);

    }
}

==

package UserInterface;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;

/**
 *
 * @author André Vinícius Lopes
 */
public class Keyboard extends JoystickModel{

  

    @Override
    public void listener() {
        moveRight = Gdx.input.isKeyPressed(Input.Keys.DPAD_RIGHT);
        moveLeft = Gdx.input.isKeyPressed(Input.Keys.DPAD_LEFT);
        shoot = Gdx.input.isKeyPressed(Input.Keys.SPACE);
        //Not Used : 
        moveUp = Gdx.input.isKeyPressed(Input.Keys.DPAD_UP);
        moveDown = Gdx.input.isKeyPressed(Input.Keys.DPAD_DOWN);
    }
    
  

   
}

At glance, it should be fine.