java.lang.UnsatisfiedLinkError:dalvik.system.PathClassLoader couldn't find .so

转载请标明出处:http://blog.csdn.net/xx326664162/article/details/52926400 文章出自:薛瑄的博客

你也可以查看我的其他同类文章,也会让你有一定的收货

首先说明出现下面这个错误的原因可能有很多,你也可以直接看下面的分析,来判断是不是和我一样的问题

测试环境:

MIUI8 Android 6.0
Android studio 2.2.2
gradle-2.14.1-all
android-ndk-r10

项目的build.gradle如下:

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"

    defaultConfig {
        applicationId "com.firs.facedetecttosvr"
        minSdkVersion 14
        targetSdkVersion 21

        ndk {
            moduleName "libface_identify"
            abiFilters 'armeabi', 'armeabi-v7a'
        }
    }
   ...(部分省略)
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
}

Android.mk配置如下

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := facetemp
LOCAL_SRC_FILES := libFiFacial.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := jpegtemp
LOCAL_SRC_FILES := libjpeg.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
#LOCAL_SRC_TCP  := ./tcpSock/maintcp.cpp ./tcpSock/CommLayerTcp.cpp ./tcpSock/NetAuth.cpp ./tcpSock/NetDeal.cpp ./tcpSock/NetPublic.cpp
#LOCAL_SRC_TCP  := maintcp.cpp CommLayerTcp.cpp NetAuth.cpp NetDeal.cpp NetPublic.cpp

LOCAL_MODULE    := libface_identify
LOCAL_SRC_FILES := facelib.cpp public.cpp  maintcp.cpp CommLayerTcp.cpp NetAuth.cpp NetDeal.cpp NetPublic.cpp gb2312.cpp
#LOCAL_MODULE_FILENAME = libface_identify
LOCAL_SHARED_LIBRARIES := jpegtemp
LOCAL_STATIC_LIBRARIES := facetemp
LOCAL_LDLIBS := -llog -lstdc++
include $(BUILD_SHARED_LIBRARY)

崩溃时的logcat

10-25 19:42:25.340 28880-28880/com.firs.facedetecttosvr W/System: ClassLoader referenced unknown path: /data/app/com.firs.facedetecttosvr-1/lib/arm
10-25 19:42:25.574 28880-28888/com.firs.facedetecttosvr W/art: Suspending all threads took: 8.180ms
10-25 19:42:25.728 28880-28893/com.firs.facedetecttosvr I/art: Background partial concurrent mark sweep GC freed 95(19KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 35MB/59MB, paused 11.051ms total 24.921ms
10-25 19:42:25.734 28880-28880/com.firs.facedetecttosvr D/AndroidRuntime: Shutting down VM
10-25 19:42:25.735 28880-28880/com.firs.facedetecttosvr E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: com.firs.facedetecttosvr, PID: 28880
                                                                          java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.firs.facedetecttosvr-1/base.apk"],nativeLibraryDirectories=[/data/app/com.firs.facedetecttosvr-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libface_identify.so"
           at java.lang.Runtime.loadLibrary(Runtime.java:367)
           at java.lang.System.loadLibrary(System.java:1076)
           at com.firs.cn.FaceNative.<clinit>(FaceNative.java:7)
           at com.firs.facedetecttosvr.WelcomeActivity.initDate(WelcomeActivity.java:46)
           at com.firs.facedetecttosvr.WelcomeActivity.onCreate(WelcomeActivity.java:29)
           at android.app.Activity.performCreate(Activity.java:6303)
           at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
           at android.app.ActivityThread.access$900(ActivityThread.java:153)
           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
           at android.os.Handler.dispatchMessage(Handler.java:102)
           at android.os.Looper.loop(Looper.java:148)
           at android.app.ActivityThread.main(ActivityThread.java:5438)
           at java.lang.reflect.Method.invoke(Native Method)
           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
10-25 19:42:25.763 28880-28880/? I/Process: Sending signal. PID: 28880 SIG: 9

解决方法:

这个办法是无意中发现的,至于原因我不知道,希望大神可以帮忙指点一下

项目的build.gradle文件中的minSdkVersion 改为19即可,更大的版本应该也是可以

关注我的公众号,轻松了解和学习更多技术
这里写图片描述

发布了244 篇原创文章 · 获赞 799 · 访问量 234万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 代码科技 设计师: Amelia_0503

分享到微信朋友圈

×

扫一扫,手机浏览