1

Im trying to integrate lame lib in my application in order to record audio in mp3 format. Today android don't support mp3 encoding natively however with some digging i have found that i can use lame lib but the problem is , lame lib is in c code. after more reading i found out the only way to make it work correctly is to use the c code into my project compile it as a library useing NDK through JNI or something like that.

My problem is that i don't really understand all this NDK and JNI and most importantly i don't know how to run native code with ANDROID STUDIO! I when to this page and read a bit about it but still they don't mention there how to do it in android studio. i am really confuse here.

My questions are:

-Please how can I integrate NDK with ANDROID studio (as far as i have read some are more lucky because its easier with Eclipse which i dont use)

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

Thank you

murielK
  • 1,000
  • 1
  • 10
  • 21
  • 1
    Seems like there is a question about this: http://stackoverflow.com/questions/8632835/lame-mp3-encoder-compile-for-android – elimirks Mar 25 '14 at 12:34
  • this method is for eclipse ... i read that also thank you – murielK Mar 25 '14 at 12:41
  • *Question #1*: yes, it is possible to use NDK with Android Studio. But it is not easy, not supported, and the workarounds have changed quite a few times in the last months. (see e.g. *[Android studio, gradle and NDK](http://stackoverflow.com/questions/16667903/android-studio-gradle-and-ndk)*). If possible, build the native libraries separately; it is possible to package prebuilt libraries for AS (*[Add pre-built .so files in project using Android Gradle plugin 0.7.3](http://stackoverflow.com/questions/20900814/add-pre-built-so-files-in-project-using-android-gradle-plugin-0-7-3)*). – Alex Cohn Jun 06 '14 at 17:47
  • *Question #2:* no, it is impossible to import the lameLib into your project without NDK. – Alex Cohn Jun 06 '14 at 17:52

1 Answers1

0

There are two steps you need to take

1: Create the JNI wrappers

You should read about JNI. It's complicated. The best way to generate wrappers for a large project is to use Swig to auto generate them. I recommend following the swig android tutorial 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 set up ndk with Android Studio.

Community
  • 1
  • 1
Cypress Frankenfeld
  • 2,317
  • 2
  • 28
  • 40