cryptopp/extras/jni
Alexander Afanasyev 3a081d5e25 Add Android.mk and Application.mk to build using android NDK 2016-01-21 18:42:59 -08:00
..
Android.mk Add Android.mk and Application.mk to build using android NDK 2016-01-21 18:42:59 -08:00
Application.mk Add Android.mk and Application.mk to build using android NDK 2016-01-21 18:42:59 -08:00
README.md Add Android.mk and Application.mk to build using android NDK 2016-01-21 18:42:59 -08:00
cryptopp-shared.mk Add Android.mk and Application.mk to build using android NDK 2016-01-21 18:42:59 -08:00
cryptopp-static.mk Add Android.mk and Application.mk to build using android NDK 2016-01-21 18:42:59 -08:00

README.md

Android NDK build files

Building independent library

CryptoPP library can be independently built using just one command:

cd <cryptopp-folder>
ndk-build NDK_PROJECT_PATH=`pwd`/extras

This will build shared library libcryptopp_shared.so in extras/libs/, static library libcryptopp_static.a in extras/obj/, and cryptest.exe binary.

Integrate CryptoPP into application

It is also possible to integrate CryptoPP into applications build process. For example, if application source has the following structure:

├── AndroidManifest.xml
├── java
│   ├── ...
│   └── ...
├── jni
│   ├── Android.mk
│   └── Application.mk
└── res
    ├── ...
    └── ...
  • Copy CryptoPP source code (or create git submodule) in jni/cryptopp.

  • In application's Android.mk add the desired version of the library.

    For shared version:

      LOCAL_PATH := $(call my-dir)
      LOCAL_PATH_SAVED := $(LOCAL_PATH)
    
      include $(CLEAR_VARS)
      LOCAL_MODULE := my-local-module
      LOCAL_SHARED_LIBRARIES := cryptopp_shared ...
      include $(BUILD_SHARED_LIBRARY)
    
      include $(LOCAL_PATH_SAVED)/cryptopp/extras/jni/cryptopp-shared.mk
    

    For static version:

      LOCAL_PATH := $(call my-dir)
      LOCAL_PATH_SAVED := $(LOCAL_PATH)
    
      include $(CLEAR_VARS)
      LOCAL_MODULE := my-local-module
      LOCAL_STATIC_LIBRARIES := cryptopp_static ...
      include $(BUILD_SHARED_LIBRARY)
    
      include $(LOCAL_PATH_SAVED)/cryptopp/extras/jni/cryptopp-static.mk