App在使用过程中遇到如下错误:
java.lang.UnsatisfiedLinkError: Couldn't load weibosdkcore from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.miaomiaobank-1.apk,libraryPath=/data/app-lib/com.miaomiaobank-1]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:355)at java.lang.System.loadLibrary(System.java:525)
at com.sina.weibo.sdk.net.HttpManager.<clinit>(HttpManager.java:83)
at com.sina.weibo.sdk.net.AsyncWeiboRunner.request(AsyncWeiboRunner.java:84)
at com.sina.weibo.sdk.utils.AidTask.loadAidFromNet(AidTask.java:307)
at com.sina.weibo.sdk.utils.AidTask.access$2(AidTask.java:294)
at com.sina.weibo.sdk.utils.AidTask$2.run(AidTask.java:159)
at java.lang.Thread.run(Thread.java:841)
上述异常的抛出是由于,项目引用的so库存放路径不对,Android Studio不能加载读取。我的项目是从eclipse迁移到Android Studio上的,项目中用到了一些so库,目录结构如下图:
解决办法有两种:
1.在build.gradle文件加入
android { ... sourceSets { main.jniLibs.srcDirs = ['libs'] test.jniLibs.srcDirs = ['libs'] } }2.将.so库放入src/main/jniLibs下, http://www.cnblogs.com/xrwang/p/AndroidStudioImportJarAndSoLibrary.html
记得之后再Tools -->Android -->sync project with gradle files一下。