Just set up a project using Android Studio 2.2.3 with Java 1.8 and Android 7 (API Level 24) trying to test the "new" java 8 feature Stream
.
Here my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.radinator.myproject"
minSdkVersion 24
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
testCompile 'junit:junit:4.12'
}
Here the code:
import java.util.stream.*;
public class MainActivity extens Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mainactivity);
}
void foo(){
List<String> myList = Arrays.asList("one", "two", "three", "four", "five", "six");
myList.stream()
.filter(s -> s.length() > 0)
.collect(Collectors.toList())
}
}
Android Studio underlines the line myList.stream()...
telling me "Usage of API documented as @since 1.8+
" Gradle is compiling everything but why do I get this message? I thought this feature is introduced with Java 8 and available under Android API Leve 24 and above?
How can I solve this mess?
Thanks in advance