Question

i want create an app or .apk file which can play video in particular format.

For this I had compiled my source files and taken object files, from object files i have generated one shared library file (.so) using command

gcc -c -fPIC hello.c -o hello.o
gcc hello.o -shared -o libhello.so 

can somebody please help me with the steps to create apk file from .so file in android Eclipse or android sdk

what is the importence of java files while creating an apk file...

Was it helpful?

Solution

From what you have put up above, i presume that you are not compiling your custom decoder code using the tool chains provided by android ndk. I have performed the same task which you are supposed to do.

First of all what you need to do is:

1) Create a Android project

2) In side the root directory of the Android project, create a folder called "jni"

3) Dump in all your "C" code (custom decoders code) into this folder.

4) Create a file in the same /jni folder which has the decoder code and name the file as Android.mk . If you know the concept of make files in linux, the same thing implies here, only the syntax changes.(you can refer to some sample examples that comes along android ndk).

5) Download Android-ndk from the developers website ( it also has sample examples you can refer them to learn it).

6) Configure PATH variable to ndk directory.

Eg: export NDK_PATH=/home/myPC/android-ndk-r7b

7) cd to jni directory and type the command ndk-build. If everyting goes well you will now have a .so file generated, which means your code has been successfully cross-compiled to android platform.

8) Now in the /src folder you will have a .java file, from which you will have to load the .so file generated. For this you can refer the sample examples in android ndk.

9) Use JNI to interface between your application and .so generated. For example if your custom decoder is designed to take an input file pointer to decode the file, the accordingly you will have to implement the JNI code.

10) Finally when you have done all, and if your decoder is providing you with RGB data, then you can use openGL ES to display the decoded pictures from the native code only.

OTHER TIPS

You need to install NDK first. Then you need to provide JNI wrapper for your library. The easiest way is to have a look into hello-jni and two-libs sample apps to learn how to do this. You will find the app under ndk_home/samples/.

I would try using ant. http://www.androidengineer.com/2010/06/using-ant-to-automate-building-android.html

Please let me know how it goes (not sure about all this .so thing).

If you have any trouble with the tutorial I linked, let me know for that too, I've been through it and could help with it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top