原创链接:http://blog.csdn.net/zhao_3546/article/details/16819609
之前实现了一个号码分析的APK,让第三方应用通过AIDL调用来分析号码。
正常情况下,都是通过手动安装此APK来实现部署的,但今天有个兄弟直接将此APK放到 /system/app/ 目录下,
第三方应用一调用这个APK的AIDL,就报了下面的异常:
- 11-19 10:23:57.198: W/dalvikvm(11342): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/zhaowei/lib/Encryption;
- 11-19 10:23:57.198: W/dalvikvm(11342): threadid=11: thread exiting with uncaught exception (group=0x4166d700)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): FATAL EXCEPTION: Thread-276
- 11-19 10:23:57.198: E/AndroidRuntime(11342): java.lang.UnsatisfiedLinkError: Couldn't load HAOMA from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/system/app/NumberQuery.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]: findLibrary returned null
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at java.lang.Runtime.loadLibrary(Runtime.java:355)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at java.lang.System.loadLibrary(System.java:525)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at com.zhao3546.lib.Encryption.<clinit>(Encryption.java:17)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at com.zhao3546.numberquery.NumberQueryService.searchOnline(NumberQueryService.java:65)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at com.zhao3546.numberquery.NumberQueryService.queryNumberImpl(NumberQueryService.java:111)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at com.zhao3546.numberquery.NumberQueryService.access$0(NumberQueryService.java:109)
- 11-19 10:23:57.198: E/AndroidRuntime(11342): at com.zhao3546.numberquery.NumberQueryService$MyThread.run(NumberQueryService.java:191)
正常情况下,正常安装的APK,都是优先去自己的打包apk中去加载对应的so文件;
但如果此将应用直接放到/system/app/下,加载so的规则会有点区别,Android会直接去 /vendor/lib, /system/lib 这两个目录下去加载对应的so,
如果加载不到,就会报上面的异常。
上面的异常信息已经明确地说明了这一点。
解决方法:
1、将 /system/app/NumberQuery.apk 删除掉,通过正常的方式来安装此apk;
2、将此apk中集成的so直接放到 /vendor/lib 或 /system/lib 目录中即可;