I downloaded Android Studio 4 and tried to test using Java 8's Streams and so on based on our application settings. Our Sdk version is 17. I updated build.gradle based on this Android Studio 4 release notes and Java 8 Support for android. But I haven't access to Java 8 features as Stream, StreamSupport or Collections.stream(). I wonder what I am missing here. I have created a basic project with Android Studio template. The Project's build gradle looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and the modules build.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5'
}
And this is the gradle.properties:
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048m
android.enableJetifier=true