dangfan / android-ndk-openssl Goto Github PK
View Code? Open in Web Editor NEWdemo project using openssl in ndk
demo project using openssl in ndk
Reading your great article: https://juejin.im/entry/56d7a4705bbb50004ca31cf5
from programing standing of point, it is fine. In practice, it is too risky with this hack way though: if OS changes something for those 2 libs in next release, the app will not function at all. If really go this way ( using the existing lib baked inside OS image, but there is NDK header/so files ), probably use dlopen()/dlsym(). that way app at least get change to check whether the required functions are supported in the running OS; plus your APK size will be smaller -- you do not have to include them inside APK.
The proposed way in the article is too risky to be used in production application, might giving local developer community wrong direction... just my personal view.
Thanks
terro,你好!非常感谢你为大家提供了这个在Android中应用OpenSSL的demo!但是,在我这里运行会报错,错误日志如下:
3-14 17:30:48.402 3617-3617/com.example.openssltest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.openssltest, PID: 3617
java.lang.UnsatisfiedLinkError: No implementation found for byte[] com.example.openssltest.MainActivity.hmacSha256(byte[]) (tried Java_com_example_openssltest_MainActivity_hmacSha256 and Java_com_example_openssltest_MainActivity_hmacSha256___3B)
at com.example.openssltest.MainActivity.hmacSha256(Native Method)
at com.example.openssltest.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:102)
我查了一下这个错误原因,网上大多数情况都是因为JNI的方法名称定义没有按照规定定义,可是在你的demo里面可以看到JNI的方法名称定义是没有问题的,所以不知道问题出在哪里,还望不吝赐教!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.