I need to generate ARM
structure shared library for a sampleCPP
project.
Sample projects contains:
Now, I want to create a shared library for a different Android project. I tried to compile with [Android-Cmake][1]
but it is generating X86
Architecture library not ARM.
Please let me know if there is another way to do it. Also can i run X86
on Android Platform for all version?
Here is my Android.mk:
LOCAL_PATH := $(call my-dir)/../ //Path is according JNI Folder
SRC_TOP_DIR := $(LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := smileParse
LOCAL_CFLAGS := -DANDROID
LOCAL_SRC_FILES := main.cpp test.cpp smamain.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include $(LOCAL_PATH)/
Create a folder called JNI in your project:
Create or Edit Android.mk in JNI folder, set include and library path,
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := some.cpp
include $(BUILD_SHARED_LIBRARY)
Declare a java wrapper class, declare a native function:
public class JWrapperSomeClass {
public native void Demo(int para);
}
use javah command to generate the function signature for your C++ method wrapper:
javah -jni -classpath bin/classes/ -d jni com.example.Your.Package.Class
Edit the code in C++
Go to your project folder, run command:
$ANDROID_NDK/ndk-build
where $ANDROID_NDK is the folder where you installed android NDK
That is pretty much it. For more details, you might read NDK or JNI documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With