1

I have a module in my Android Studio project, which is a Java Library, in there I wrote a function like this:

 private boolean titleIsNotEmpty(Event event){
        return event.getTitle().trim().isEmpty();
 }

But on isEmpty() I get the following message:

Call requires API level 9 (current min is 1) Java.lang.String#isEmpty

Also when I try to use Function or Optional classes I get the same error:

Call requires API level 24 (current min is 1)

How can I define that on a Java Library?, my gradle build.module is:

apply plugin: 'java'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

sourceCompatibility = "1.8"
targetCompatibility = "1.8"

Thanks in advance

J. Pichardo
  • 2,819
  • 18
  • 36
  • simply the definitions of these functions and API's were added to respected versions so set your complied/target version to 24 in your case to use these functionalities – Pavneet_Singh Oct 02 '16 at 06:59
  • @PavneetSingh So those compatibility options do not refer to the Java Binary? – J. Pichardo Oct 02 '16 at 07:29
  • it's trade off , you want some feature you lose some backward support , many features don't have backward compatibility with v4,v7 – Pavneet_Singh Oct 02 '16 at 08:19

3 Answers3

0

maybe you can try this add to your java module

@SuppressLint("NewApi")
    @TargetApi(Build.VERSION_CODES.KITKAT)
-1

Your current min SDK is 1...

You must look in your build.gradle after this line:

minSdkVersion **

You must cange the ** to your required SDK. For example 24

minSdkVersion 24
ThisaruG
  • 2,382
  • 5
  • 34
  • 50
  • 1
    Thanks @Tim but again, that option works within the android section of the `build.gradle` file of an android module, in a Java Module I cannot add that, I've already tried it. – J. Pichardo Oct 02 '16 at 07:10
  • Ok, I know what you mean. –  Oct 02 '16 at 07:12
-1

I've seen this behavior if you're using android studio and you only have a JAR module in the project.

Just ignore it.

spy
  • 2,952
  • 1
  • 14
  • 25