problem of string.isEmpty in Android 2.2 revision 3

142 views
Skip to first unread message

giang

unread,
Oct 16, 2011, 11:37:23 AM10/16/11
to JTwitter
I'm developing a twitter client on Android API 8 revision 3 and I
found that when receiving json response from Twitter, JTwitter throw
this exception:

E/AndroidRuntime( 389): java.lang.NoSuchMethodError:
java.lang.String.isEmpty
E/AndroidRuntime( 389): at
winterwell.jtwitter.Status.jsonGetLocn(Status.java:102)
E/AndroidRuntime( 389): at
winterwell.jtwitter.User.<init>(User.java:155)
E/AndroidRuntime( 389): at
winterwell.jtwitter.Status.<init>(Status.java:243)
E/AndroidRuntime( 389): at
winterwell.jtwitter.Status.getStatuses(Status.java:55)
E/AndroidRuntime( 389): at
winterwell.jtwitter.Twitter.getStatuses(Twitter.java:1527)
E/AndroidRuntime( 389): at
winterwell.jtwitter.Twitter.getHomeTimeline(Twitter.java:1056)
E/AndroidRuntime( 389): at com.kaist.zang.UpdaterService
$Updater.run(UpdaterService.java:104)

which I believe is because of the present of location information in
the response.

I look into the source code of jtwitter then found isEmpty function is
called in this function when process geocoding:

static Object jsonGetLocn(JSONObject object) throws JSONException {
String _location = InternalUtils.jsonGet("location", object);
// no blank strings
if (_location != null && _location.isEmpty()) {
_location = null;
}

Is there any idea? I think this should be using String.trim().size()
== 0

THank you

Daniel Winterstein

unread,
Oct 19, 2011, 9:16:44 AM10/19/11
to jt...@googlegroups.com
Hi Giang,

Sorry for the slow response on this!
String.isEmpty() is a Java 1.6 method, but it seems not supported in Android.
I have edited the code to remove it.
If you get the latest version
(http://www.winterwell.com/software/jtwitter.php) this is fixed.

Best regards,
- Daniel

--
--------------------------------------------------
Daniel Winterstein
Edinburgh
http://winterwell.com   http://soda.sh

Reply all
Reply to author
Forward
0 new messages