How to add native code for Android in LibGDX?

I want to write my own code for my Android application. I added 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 that will be called from my Android game.

I am using Android Studio.

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

sourceSets { main { jni.srcDirs = 'cppsrc' jniLibs.srcDirs = ['libs'] } } 
+6
source share
2 answers

Have you tried jnigen? jnigen is a small library that can be used with or without libgdx, which allows you to write C / C ++ code embedded with Java source code. Please read this on the LibGDX JNIGEN website

0
source

When you create a LibGDX project, there is a separate project directory. Core, Desktop, Android, iOS, HTML. You can add Android code to the Android projects directory using java. I did it, and it can be done easily. This is exactly the same as recording an Android program with the LibGDX game class as its type.

-1
source

All Articles