Android N Preview中的Java 8
作者:互联网
官方Java 8 announcement for Android N Preview说如下:
With Android’s Jack compiler, you can now use many popular Java 8
language features, including lambdas and more, on Android versions as
far back as Gingerbread. (…) Some Java 8 language features — like
default and static methods, streams, and functional interfaces — are
also now available on N and above.
我正在使用minSdkVersion 15的以下gradle配置在一个小项目中尝试一些Java 8:
android {
compileSdkVersion 'android-N'
buildToolsVersion '24.0.0 rc1'
defaultConfig {
applicationId "org.sergiiz.thermometer"
minSdkVersion 15
targetSdkVersion 'N'
versionCode 1
versionName "1.0"
jackOptions{
enabled true
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
//...
}
但部署目标选择器显示minSdk(API23,N预览).这是预期的行为吗?
是否有可用于Gingerbread的Java 8功能/软件包列表,您知道在API< 23上使用Java 8功能需要哪些gradle设置或支持库吗?
解决方法:
But the Deployment Target selector shows minSdk(API23, N preview). Is it expected behaviour?
是. N Developer Preview设置为仅在N个设备上运行.你的targetSdkVersion’N’行隐含地将你的minSdkVersion改为N.
do you know which gradle settings or support libs are needed to use Java 8 features on API<23?
我建议您不要担心旧设备上的Java 8功能,直到Android N退出“开发人员预览”模式或Android工具团队提供特定的非N指令.
标签:android,android-gradle,android-7-0-nougat,android-n-preview 来源: https://codeday.me/bug/20190702/1355017.html