Scala on Android: java.lang.NoSuchMethodError: java.lang.String.isEmpty

懵懂的女人 提交于 2019-12-19 17:14:51

问题


I am getting following Exception on Android 2.2.1:

java.lang.NoSuchMethodError: java.lang.String.isEmpty

I am calling text.isEmpty from Scala. Any idea, how to solve this?


回答1:


Use JRE/JDK 1.5, which did not have an isEmpty method on String. This will avoid situations where Scala uses 1.6's isEmpty instead of its own. If you have Java libraries as well, be sure to pick ones compatible with 1.5.




回答2:


java.lang.String.isEmpty() was added in Gingerbread (2.3). You will have to write your own replacement function...




回答3:


Alternativly use (text.length()>0) ?




回答4:


Use TextUtils.isEmpty() instead, available since API level 1.



来源:https://stackoverflow.com/questions/4396844/scala-on-android-java-lang-nosuchmethoderror-java-lang-string-isempty

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