c - How to add openssl lib in android studio with experimental gradle plugin (NDK)? -


i'm trying add openssl library project in android studio 2.0 preview 7 experimental gradle plugin.

dependencies {     classpath 'com.android.tools.build:gradle-experimental:0.4.0' } 

what did downloaded openssl library , put jni folder. , have .c file uses library. have included files need , there no errors in code. .c file name hello-jni.c , declared build.gradle (module: app) this:

android.ndk {     modulename = "hello-jni" } 

and loaded library in mainactivity this:

static {     system.loadlibrary("hello-jni"); } 

but when try build project, error shows this:

error:(51) undefined reference `rsa_generate_key' error:error: ld returned 1 exit status error:execution failed task ':app:linkarm64-v8adebughello-    jnisharedlibrary'. > build operation failed.   linker failed while linking libhello-jni.so. 

my hello-jni.c source code:

#include <jni.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include "boringssl/crypto/openssl/base.h" #include "boringssl/crypto/openssl/rsa.h" #include "boringssl/crypto/openssl/pem.h"  #define key_length  2048 #define pub_exp     3 #define print_keys #define write_to_file 0  size_t pri_len;            // length of private key size_t pub_len;            // length of public key char   *pri_key;           // private key char   *pub_key;           // public key char   msg[key_length/8];  // message encrypt char   *encrypt = null;    // encrypted message char   *decrypt = null;    // decrypted message char   *err;               // buffer error messages  jniexport jstring jnicall java_com_example_ndktest_signupactivity_teststring(jnienv *env, jobject activity) {  // in line, error happens!(in build time) rsa *keypair = rsa_generate_key(key_length, pub_exp, null, null);  //continue work key pair ...  return "some jstring"; } 

you need specify openssl library dependency. there's snippet here showing how add prebuilt library.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -