Methods to build out so file
Method1
In gradle file add:
Default config{
ndk {
moduleName "shape-detect"
cFlags "-DANDROID_NDK -D_DEBUGDNULL=0" // Define some macros
ldLibs "EGL","GLESv3", "dl", "log" // Link with these libraries!
stl "stlport_shared" // Use shared stlportlibrary
}
}
No further support by android studio gradle anyway,not suggest to use
Method2
sourceSets.main{
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
// call regular ndk-build(.cmd) scriptfrom app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)){
commandLine 'ndk-build.cmd', '-C',file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C',file('src/main').absolutePath
}
}
From<http://stackoverflow.com/questions/29738953/ndkbuild-failure>
Meet the error and doesn't know how to fix:
Error:Executionfailed for task ':app:ndkBuild'.
> A problemoccurred starting process 'command 'ndk-build.cmd''
Method3
In cmd build out so
C:\Users\wiwu\Desktop\Android\android-ndk-r10e>
ndk-build.cmd -CE:\Workspace\CoA\android-dss\DSS\ThirdPartySDK\MockedTorque\app\src\main\jni
ndk-build.cmd -CC:\Users\wiwu\Downloads\OpenSSL1.0.1cForAndroid-master\OpenSSL1.0.1cForAndroid-master
ndk-build -CE:/Workspace/CoA/android-dss/DSS/ThirdPartySDK/ThirdPartySDKUnionPayDemoApp/Openapi/src/main/jni
ndk-build -CE:/Workspace/CoA/android-dss/DSS/Openapi/src/main/jni
How to compile static library
http://stackoverflow.com/questions/2943828/how-to-compile-a-static-library-using-the-android-ndk
Where is the windows system headers and library's location
C:\Users\wiwu\Desktop\Android\android-ndk-r10e\platforms\android-21\arch-arm\usr
Error undefinedreference
Such undefinedreference errorstypically indicate that the compiler/linker did not find libcrypto.so in it'spath. You could try a couple of things:
From<http://stackoverflow.com/questions/18941072/how-to-integrate-openssl-to-android>
non-system libraries in linker flags
Java byte[] to char*
How to write JNI
http://blog.csdn.net/xyz_lmn/article/details/6959545
http://www.cnblogs.com/luxiaofeng54/archive/2011/08/15/2139934.html
MD5
http://www.askyb.com/cpp/openssl-md5-hashing-example-in-cpp/
RSA
http://hayageek.com/rsa-encryption-decryption-openssl-c/
RSA是常用的非对称加密算法。近来有学生在项目中使用System.Security类库中的RSA加密算法时,出现了“不正确的长度”,这实际上是因为待加密的数据超长所致。.net
Framework中提供的RSA算法规定,每次加密的字节数,不能超过密钥的长度值减去11,而每次加密得到的密文长度,却恰恰是密钥的长度。所以,如果要加密较长的数据,可以采用数据截取的方法,分段加密,实现如下:
http://travistidwell.com/jsencrypt/demo/
http://travistidwell.com/blog/2013/09/06/an-online-rsa-public-and-private-key-generator/