This demo project on GitHub.

How to add libgdx to a native Android project

I suggested generating a libgdx project, that way it’s easier.

So, you have an android project.

Update your app’s build.gradle file:

 1. Add the properties after the line apply plugin: '' (alternatively, you can copy them from your libgdx project):

ext {
    appName = "AndroidLibgdx"
    gdxVersion = '1.9.9'
    roboVMVersion = '2.3.6'
    box2DLightsVersion = '1.4'
    ashleyVersion = '1.7.0'
    aiVersion = '1.8.0'

 2. Inside android paste this code:

    //other code
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']

 3. Add this line before dependecies:

configurations { natives }

 4. Add libgdx dependencies:

dependencies {
    //Other dependencies you have

    implementation "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
    implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
    natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"

    implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
    implementation "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"

    implementation "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
    implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    implementation "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"

And look up other dependencies you need by either generating a new libgdx project and copying them or you can look them up here.

 5. Add this task to the end of your file:

task copyAndroidNatives() {

    configurations.getByName("natives").copy().files.each { jar ->
        def outputDir = null
        if ("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
        if ("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if ("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
        if ("natives-x86.jar")) outputDir = file("libs/x86")
        if ("natives-x86_64.jar")) outputDir = file("libs/x86_64")
        if (outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"

 6. Open your file and paste this line:


Now, you should have libgdx integrated.

How to use libgdx in your Android project

 1. You should add the android launcher for libgdx. In my demo it looks like this:

public class Launcher extends AndroidApplication {
    protected void onCreate (Bundle savedInstanceState) {
        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new MyGame(), config);

 2. Then, you should copy your ApplicationAdapter class, which is basically your libgdx game. In my demo I used the default:

public class MyGame extends ApplicationAdapter {
    SpriteBatch batch;
    Texture img;

    public void create () {
        batch = new SpriteBatch();
        img = new Texture("badlogic.jpg");

    public void render () {, 0, 0, 1);;
        batch.draw(img, 0, 0);

    public void dispose () {

 3. Don’t forget to add the launcher to your manifest:

        //other code
        <activity android:name=".Launcher" />

 4. Lauch your libgdx game as an Intent in your main activity:

startActivity(new Intent(this, Launcher.class));

Hope everything worked. Good luck developing!