简体   繁体   中英

Android Studio - MinSdkVersion on Java Library

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

maybe you can try this add to your java module

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

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

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

Just ignore it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM