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

android, android-studio

Solution

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
    }
}

Problem

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?

Original source