Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add native android code to LibGDX?

I want to write native code for my Android app. I followed this tutorial to add CPP files to my project. It compiles, but it conflicts with LibGDX.

How can I combine this with LibGDX?

I want to know how to add a simple CPP file with one function which will be called from my Android game.

I am using Android Studio.

When I add jni path to my Android gradle, LibGDX stops working:

sourceSets {
    main {
        jni.srcDirs = 'cppsrc'
        jniLibs.srcDirs = ['libs']
    }
}
like image 306
Z0q Avatar asked Mar 10 '16 13:03

Z0q


1 Answers

Have you tried jnigen? jnigen is a small library that can be used with or without libgdx which allows C/C++ code to be written inline with Java source code. Read this please from LibGDX site JNIGEN

like image 110
Carlos Avatar answered Sep 30 '22 17:09

Carlos