首页 > 代码库 > android 使用讯飞人脸识别api报错:java.lang.UnsatisfiedLinkError

android 使用讯飞人脸识别api报错:java.lang.UnsatisfiedLinkError

1、在做一个人脸识别的项目,使用的是讯飞的api,编辑器为AS2.0,运行时报如下错误:

 FATAL EXCEPTION: main
                  Process: com.admin.smartcam, PID: 13821
                  java.lang.UnsatisfiedLinkError: Native method not found: com.faceplusplus.api.Native.setMinFaceSize:(II)I
                      at com.faceplusplus.api.Native.setMinFaceSize(Native Method)
                      at com.faceplusplus.api.FaceDetecter.setMinFaceSize(FaceDetecter.java:124)
                      at com.admin.smartcam.detectionface.DetectionFace.<init>(DetectionFace.java:21)
                      at com.admin.smartcam.androidcamera.camera.BitmapCallback.PictureCallbackToBitmap.onPictureTaken(PictureCallbackToBitmap.java:26)
                      at android.hardware.Camera$EventHandler.handleMessage(Camera.java:940)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:136)
                      at android.app.ActivityThread.main(ActivityThread.java:5111)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
                      at dalvik.system.NativeStart.main(Native Method)

2、分析【可能是因为系统找不到我的.so文件】

工程目录如下:

技术分享

3、解决办法:

打开build.gradle文件添加如下代码:

    sourceSets {
        main {
            jniLibs.srcDirs = [libs]
        }
    }

技术分享

 

至此就ok了!

android 使用讯飞人脸识别api报错:java.lang.UnsatisfiedLinkError