Android NDK in Android Studio [duplicate] - android

This question already has answers here:
How to configure NDK with Android Gradle plugin 0.7
(5 answers)
Android studio, gradle and NDK
(23 answers)
Closed 8 years ago.
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

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.

Related

Can or how Android studio use c++ static library *.lib (compiled for windows)?

Our project needs a third party library from another company and it is not open source. They provided *.h and *.lib compiled for windows (linux as well), but no cpp.
I didn't think android could use it but I still have tried it in NDK because I have never touch android studio before.
There are many questions, but it all comes to the question, is it possible to use *.lib in android studio(or VS cross-compile) without the cpp of that library?
If the answer is no, I think the only option for us is to request the android version of the library (*.so and *.a files). Is this correct?

How to use latest FFMPEG in Android Studio project?

I have a simple task to make a video from multiple images and an audio file, After searching a lot found that its possible with FFMPEG, Unfortunately there are no updated tutorials for FFMPEG, there are few but outdated and most of them are not working.
As I have compiled FFMPEG for Android using NDK android-ndk-r10e and ffmpeg-2.8.6 on my MAC with Android Studio following the tutorial http://www.roman10.net/how-to-build-ffmpeg-with-ndk-r9/
It makes the .so files as
Now I can't understand what should I do to integrate this in my Android project, I have also checked,
How to use Ffmpeg in android studio?
how to use ffmpeg in android?
FFmpeg on Android
and mainly this,
http://www.roman10.net/how-to-build-android-applications-based-on-ffmpeg-by-an-example/
https://github.com/roman10/android-ffmpeg-tutorial
But its not working and having errors with no way to resolve this. Can anyone please mention some steps that should be followed to use FFMPEG .so files as in image attached.
There's a very easy solution for this, There's a precompiled library for android, as below https://github.com/WritingMinds/ffmpeg-android-java
Simply include this as a gradle project in your code and add few methods as per their documentation and you are done with FFMPEG commands in android.
This library is not very updated and have some missing features but still its good to use for many simple tasks.

Setting Up Android with OpenCV [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
OpenCV on Android Using Eclipse
What is a good site that explains how to configure the Android SDK to build Android apps with OpenCV?
I set up an Android app with OpenCV yesterday.
There are two ways to go about it
Use OpenCV for Android
Use JavaCV
OpenCV for Android is more fully supported than JavaCV. Follow Google's instructions to install Eclipse, the Android SDK and NDK (don't forget the NDK! It is needed to run C++ code. Your apps will mysteriously crash without it). Afterwards, follow this tutorial to install openCV. Try out the sample applications.
Alternatively, you can try using JavaCV instead of OpenCV for Android. This means you won't need to setup the Android NDK. It also means you won't need to write any C++. I didn't try this. But I suspect it is easier. The downside is: it doesn't support everything OpenCV does.

OpenCV on Android Using Eclipse

I'm having a hell of a time importing OpenCV into my Android project. I've already tried this tutorial:
http://opencv.itseez.com/doc/tutorials/introduction/android_binary_package/android_binary_package.html
and it did not work because Eclipse would not recognize the existing projects in the directory. So after much searching I came across this trunk:
https://code.ros.org/svn/opencv/trunk/opencv/
and was able to import it into my workspace in Eclipse. Eclipse now recognizes the sample projects, but now the problem is that there are no OpenCV library files. So all the calls to import different classes result in errors. Shouldn't there be a opencv.jar somewhere? I've seen various posts that mention having to build the library but unfortunately I don't have the slightest clue how to do that. I need something with step by step instructions. I'm running Windows 7 64-bit.
Thanks!
You should download the latest OpenCV 4 Android here:
http://opencv.org/downloads.html
And read these tutorials to get you started (in this order roughly):
Introduction into Android Development
OpenCV4Android SDK
Android Development with OpenCV
OpenCV4Android Reference
If you want to use OPEN CV in your android apps, for example if you need to read some strings from an image in your android and you are new in using OPEN CV. Then download the pre-built OpenCV library for Android from here:
http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.3/
After downloading, import OpenCV-2.3.1 into Eclipse using File-->Import...-->General-->Existing Project Into Workspace.
In your project's properties, Under Android, add the OpenCV2.3.1 library (press Add.. on the right and select OpenCV2.3.1).
Good luck!
You might want to take a look at this project: https://github.com/billmccord/OpenCV-Android
I was able to run opencv applications on my android phone with the help of this port.
installed the Win-superpack?
I recommend getting the latest .tar, extract and use it. Worked for me.
I posted about this on a duplicate question. Make sure you have the android NDK installed! Or, consider using JavaCV instead. It is much easier to install.

Building .so libraries on windows for use on android

I am building C libraries that will be used by an android app(through either JNI or the NDK, I've never used the NDK though) and I am wondering what IDE/development environment is best to use? I've basically only used Visual Studio for native development and I'm not sure how to adapt to building .so libraries for use on android.
Thanks
EDIT: Update -- I want to avoid makefiles if possible (never used them) and rather use a complete IDE such as the case with visual stuido to compile
Generally, cygwin (i.e. command line) is used for building Android native code. But you can also try to use Eclipse for this purpose. It doesn't help very much but it highlights syntax and you don't have to switch to other apps to write code and build your app. You can read more about using Eclipse for C/C++ Android development here.
I would strongly recommend that you use the NDK's compiler.
Normally this is done by writing an Android.mk in accordance with the instructions for the NDK. It is not complicated. The easiest thing to do is to grab the hello-jni sample app and just make the necessary changes, for example substituting your source files into its android.mk.
You can stay in visual studio if you like that as an editing environment, simply using the ability to bind an external command to a keystroke to launch the ndk build script. Ages ago I had figured out how to reformat GCC error messages with sed into something that VS could parse to make them click-able, though I soon moved development of that project under linux.
I think a lot of people use Eclipse as their IDE for Android development. I use it and its pretty good. You shouldn't have any problems if you're used to VS.
The Android SDK comes with a plugin, the Android Development Tools (ADT), to develop applications for Android inside the Eclipse IDE, which is same kind of beast as Visual Studio. And within that IDE, it is possible to use JavaCPP (disclaimer: I am the author) to have it compile all the native C/C++ stuff we need through the Android NDK, but without needing Makefiles and such. More details here:
http://code.google.com/p/javacpp/#Instructions_for_Android

Categories

Resources