Issue
I'm testing JNI on Android in Eclipse.
I have a simple Android project with one activity. In Eclipse's project explorer, I added:
jni/folderAndroid.mkin thejni/folderprng.cin thejni/folder
The source file is named prng.c because it wraps Crypto++'s random number generator. Crypto++ is already cross-compiled for ARMv7, so I have libcryptopp.so standing by.
When I select Project → Build Project, the library is not built. I've confirmed its not built after cleaning the project, too.
Android-PRNG$ find . -iname *.so
Android-PRNG$
Question: Why is Eclipse not building the shared object? What else need to be done?
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := prng
LOCAL_SRC_FILES := prng.c
include $(BUILD_SHARED_LIBRARY)
prng.c
Its basically empty at the moment because I can't get javah to run on the Java class file that calls the native methods. I hope to fix that problem next.
#include <string.h>
#include <jni.h>
#include <cryptopp/osrandom.h>
static RandomNumberGenerator& GetPRNG()
{
static AutoSeededRandomPool prng;
return prng;
}
Solution
It's actually very easy with ADT for the last couple of years; it was much worse before. The plugin described in the linked post are coming preinstalled; you still need to
1 install NDK
2 set the path to it in Preferences/Android/NDK menu
3 right click on your Android project, Android Tools/Add Native Support
... and now you are all set.
Answered By - Alex Cohn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.