Home > Net >  Java 11 stripLeading() method unavailable in Android Studio Arctic Fox
Java 11 stripLeading() method unavailable in Android Studio Arctic Fox

Time:01-30

In Java 11 there are some new String methods - strip(), stripLeading() etc. But it is not possible to use them in Android Studio Arctic Fox - when I try to type them, they aren't recognized:

enter image description here

I have Java 11 installed, in Settings the embedded JDK version 11.0.10 is specified:

enter image description here

In the build.gradle file, in compileOptions, I have changed to JavaVersion.VERSION_11:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

Why aren't the new methods available?

CodePudding user response:

I have Java 11 installed, in Settings the embedded JDK version 11.0.10 is specified

That is the version of Java used to run Gradle. It is unrelated to the version of Android that is used on Android devices.

In the build.gradle file, in compileOptions, I have changed to JavaVersion.VERSION_11

That does not change what is on Android devices.

Why aren't the new methods available?

Because Android supports a subset of Java 8.

CodePudding user response:

Maybe try refreshing the project? I also suggest looking at this thread: How to upgrade an Android project to Java 11

  •  Tags:  
  • Related