Android Studio: Extension Methods are not supported at this language level -
the following code produced error "extension methods not supported @ language level" in android studio:
public interface test { static string test2(string a) { return ""; } }
as 2.0 beta 2
what have done wrong?
you're trying use static interface method, feature new in java 8. not supported in android until android n. more information see use java 8 language features form android guides.
still there's bug moment.
you have use java 8 compile following mentioned instructions. here's example of build.gradle
:
apply plugin: 'com.android.application' android { compilesdkversion 'android-n' buildtoolsversion "24.0.0-rc3" defaultconfig { applicationid "example.com.examplejdk8" minsdkversion 24 targetsdkversion 'n' versioncode 1 versionname "1.0" jackoptions { enabled true } } compileoptions { sourcecompatibility javaversion.version_1_8 targetcompatibility javaversion.version_1_8 } buildtypes { release { minifyenabled false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile filetree(dir: 'libs', include: ['*.jar']) testcompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:24.0.0-alpha2' compile 'com.android.support:design:24.0.0-alpha2' }
Comments
Post a Comment