Crypto++ in Android(Java project)
This is Android side.
We can get libcryptocpp.so. Next is to use this library from Android side.
We need special settings to use libcryptocpp.so
Add Application.mk to build C++ env
Application.mk is appliction makefile common settings.
The contents is
APP_ABI := armeabi APP_CPPFLAGS += -fexceptions -frtti #APP_STL := stlport_shared APP_STL := gnustl_shared
These are common settings for C++ build
Examples
Prepared 2 directories under jni.
Top level Android.mk is following
include $(call all-subdir-makefiles)
Only calling sub directory Android.mk
cryptocpp is crytocpp core library and headers.
I put libcryptocpp.so under it.
Android.mk is following.
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := cryptopp LOCAL_SRC_FILES := libcryptopp.so LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include include $(PREBUILT_SHARED_LIBRARY)
This wraps libcrytocpp.so build.
All shared libraries move under armeabi including STL.
crypt_user has codes of this project, it is JNI codes.
This is header example
#include <jni.h> #include <cryptlib.h> #include <iostream> #include <iomanip> using namespace std; #ifndef _Included_Crypt_User #define _Included_Crypt_User #ifdef __cplusplus extern "C" { #endif // JNI method description #ifdef __cplusplus } #endif #endif
In JNI, we need define method in extern C in Android.
Problem
std:string part doesn’t work. So I gave up std:string codes.
Instead I use byte array and jbyteArray in Android
char * is also fine I thought.
You could definitely see your enthusiasm within the paintings you write. The arena hopes for even more passionate writers like you who are not afraid to say how they believe. At all times go after your heart.