Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio error: static interface method invocations are not supported in -source 1.7

Error:(100, 48) error: static interface method invocations are not supported in -source 1.7 (use -source 8 or higher to enable static interface method invocations)

the line looks like this:

field = SomeInterface.someMethod("","","");

and the interface:

public interface SomeInterface extends AnotherInterface {
      public static SomeInterface someMethod(String arg1,String arg2,String arg3) throws IOException {
            return someMethod(arg1,arg2,arg3,SOME_CONSTANT,ANOTHER_CONSTANT);
      }
}

How to fix this?

like image 570
maysi Avatar asked May 26 '26 13:05

maysi


1 Answers

Since static interface method invocations were introduced in Java 8, you have to add the Java 8 compatibility options in your build.gradle file to enable Java 8 language features:

android {
    ...
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}
like image 174
Floern Avatar answered May 30 '26 05:05

Floern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!