Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSoup 1.6.0 on Android throws Exception: String.isEmpty() NoSuchMethodExists

I'm trying to use JSoup 1.6.0 with my Android application and it throws a NoSuchMethodExists exception.

This other question tells me that isEmpty() was not added to Java JRE until 1.6 -- I've checked my JRE in eclipse, and it is 1.6, however when I try to run my app on my emulator it throws the above exception. Is there a fix, or should I just import the Apache Commons Lang library?

like image 469
Brian D Avatar asked Jan 20 '23 12:01

Brian D


1 Answers

String.isEmpty() isn't available until API level 9. Instead, you can use TextUtils.isEmpty().

It looks like JSoup 1.6 introduced code that uses String.isEmpty() and therefore will require Android API level 9. I would suggest using an older release of JSoup for now if you are targeting Android API level 8 or lower (Froyo).

This is being treated as a bug in JSoup 1.6.0 and you can expect a fix soon. See https://github.com/jhy/jsoup/issues/103 for status.

like image 135
Steve Prentice Avatar answered Jan 22 '23 00:01

Steve Prentice