java.lang.UnsatisfiedLinkError: Couldn't load hyphenate_av from loader dalvik.system.PathClassLoader
android studio引入第三方库时报如下异常。
06-15 16:50:24.477 9497-9497/easemobim.test.com.easemobim E/AndroidRuntime: FATAL EXCEPTION: main java.lang.UnsatisfiedLinkError: Couldn't load hyphenate_av from loader dalvik.system.PathClassLoader[dexPath=/data/app/easemobim.test.com.easemobim-1.apk,libraryPath=/data/app-lib/easemobim.test.com.easemobim-1]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java:365) at java.lang.System.loadLibrary(System.java:535) at com.hyphenate.chat.EMClient.loadLibrary(Unknown Source) at com.hyphenate.chat.EMClient.getInstance(Unknown Source) at easemobim.test.com.easemobim.MainActivity.onCreate(MainActivity.java:57) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5069) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) at dalvik.system.NativeStart.main(Native Method)
原因是android studio导入so文件没有编译到apk里面去,所以导致UnsatisfiedLinkError异常
打开app下的build.gradle,在android的标签下加入如下代码:
sourceSets { main { //jni库的调用会到资源文件夹下libs里面找so文件 jniLibs.srcDirs = ['libs'] } }
如:
android { ... ... sourceSets{ main{ jniLibs.srcDirs = ['libs'] } } ... ... }
扫描公众号,关注更多信息
---------------------------------------------------------------------------------我是分割线--------------------------------------------------------------------------to be a better me, talk is cheap show me the code
版权所有,转载请注明原文链接。
文中有不妥或者错误的地方还望指出,以免误人子弟。如果觉得本文对你有所帮助不妨【推荐】一下!如果你有更好的建议,可以给我留言讨论,共同进步!
再次感谢您耐心的读完本篇文章。
----------------------------------------------------------------------------------------------------------------------------------------------------------------------