Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use it in the Android APP? #53

Open
d9x2knv7 opened this issue Jun 16, 2016 · 4 comments
Open

How to use it in the Android APP? #53

d9x2knv7 opened this issue Jun 16, 2016 · 4 comments

Comments

@d9x2knv7
Copy link

Hi, I am sorry to ask this basic question in here.
I am using the Android Studio to build an application (using Java language mainly), can some one tell me how to import FFTS to the application and test it? Which part I should import into?
Thank you.

@jaadelgren
Copy link

Hi d9x2knv7,

I've been using this library for some time now in Android. In order to build for Android, you have to have the NDK tools installed on your computer (a quick google search should help). I personally code a lot in C, so I use all of the functions natively in my C code (not in Java). Anyway, building native code for Android requires you to use an Android.mk makefile; I'll attach the one I use (I renamed it to Android.txt to make github happy). Now you have to put the source code in the folder app/src/main/jni (you can copy and paste the entire ffts project folder there). So you'll have something like app/src/main/jni/ffts now, with all of the source code and other stuff.

Inside the Android.txt (which you should rename to Android.mk and place in the app/src/main/jni folder), make sure the LOCAL_PATH variable points to the correct directory where your ffts folder is. You shouldn't have to modify anything else.

You'll also need a file called Application.mk inside your app/src/main/jni. I've attached mine (again with .txt). You might need to edit it if you're targeting a different CPU architecture. With those files, you should be able to run the command ndk-build from the app/src/main/jni folder and it'll build a file called either libffts.so or libffts-neon.so inside the folder app/src/main/libs/armeabi-v7a (or armeabi-somethingElse if you're building for a different architecture).

Unfortunately, you're still not done. In order to use the library from Java, you have to use something called the JNI, the Java Native Interface. Take a look at the file ffts_jni.c inside the ffts folder for examples. That should help you get started. Good luck :) Hopefully this will help you and others avoid some of the frustration I faced when building this library. You'll probably have to do some more research on the JNI and NDK, but I'll leave that up to you.

Android.txt
Application.txt

@d9x2knv7
Copy link
Author

Thank you for you help! Thank you, I am working on it right now! Trying to study some basic way to make this happen! Thank you again!

@jaadelgren
Copy link

No worries :) glad I could help out--I know from experience how much of a hassle it can be. Hope you get it all figured out!

@dzungpv
Copy link

dzungpv commented Nov 24, 2016

Anyone can make it work with Android studio and NDK 13b?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants