Android NDK in Android Studio

I am trying to integrate lame lib in my application to record mp3 audio. Today, android does not support mp3 encoding initially, but with some digging, I found that I can use lame lib, but the problem is that lame lib is in c-code. after more reading, I found out that the only way to make it work correctly is to use the c code in my project, compile it as a library using the NDK via JNI or something like that.

My problem is that I really don’t understand all these NDK and JNI, and most importantly, I don’t know how to run my own code with ANDROID STUDIO! I’m on this page and read a little about it, but still they don’t mention how to do this in the Android studio. I'm really confused here.

My questions:

-Please, how can I integrate NDK into ANDROID studio (as far as I read, some of them are more successful, because it is easier with Eclipse, which I do not use)

- Is there any other way to use or import lameLib into my project without NDK?

thanks

+1
source share
1 answer

You need to follow two steps

1: Create JNI Wrappers

You should read about JNI. It's complicated. The best way to create wrappers for a large project is to use Swig to automatically create them. I recommend following the swig android instructions to learn swig. http://www.swig.org/Doc2.0/Android.html

2: Run ndk-build automatically in Android Studio

See my answer to another question for detailed instructions on how to configure ndk using Android Studio.

0
source

All Articles