Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 696
TN. Avatar asked Dec 09 '10 09:12

TN.


People also ask

What causes Java Lang NoSuchMethodError?

NoSuchMethodError is a runtime error in Java which occurs when a method is called that exists at compile-time, but does not exist at runtime. The Java Garbage Collector (GC) cannot free up the space required for a new object, which causes a java. lang. OutOfMemoryError .

What is Exception in thread main Java Lang NoSuchMethodError?

NoSuchMethodError: main Exception in thread "main" can come due to various reasons like: 1) The class which you are trying to run doesn't have the main method. 2) The signature of the main method is not correct. See here for all possible signatures of the main method in Java.


2 Answers

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

like image 185
Reuben Scratton Avatar answered Oct 26 '22 17:10

Reuben Scratton


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.

like image 27
Daniel C. Sobral Avatar answered Oct 26 '22 18:10

Daniel C. Sobral