Android: On some devices I get NoSuchMethodError when calling method of linked library

一笑奈何 提交于 2019-12-08 11:06:25

问题


I've added external library (ksoap2) to my Android project.

On most devices it works ok (Android 2.3). But on others (also Android 2.3) I get

java.lang.NoSuchMethodError: org.ksoap2.serialization.SoapObject.getPropertyAsString

What can be the reason of such error?


回答1:


1) There might be mulitple jars (native libraries) with same code, which may cause wrong class get loaded.

2) Incompatable version of jar, the jar you have in classpath might be older version/newer version.

I strongly suspect in your case it is first. I guess you have two versions of native libraries on the devices where it is failing.




回答2:


It may be that the device's implementation of Java does not contain the jars the ksoap library is dependent on. Remember that Android devices does not support full Java SE, although it supports most of it.

Edit: Oops, I just realized the 'no such method error' was in the Soap package, so my explanation does not hold water. :-)



来源:https://stackoverflow.com/questions/9231654/android-on-some-devices-i-get-nosuchmethoderror-when-calling-method-of-linked-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!