2

I built a demo app in Android with a minimum SDK version 24. After I finished, I was informed that we only have test devices with SDK 23 (I was using my own device to develop) and that I would need to downgrade. To do this, I changed the minSdkVersion in my app.gradle from 24 to 23. Now, I am getting errors for all occurences of forEach (as expected), but I am still able to use lambda expressions, even though those are also a Java 8 feature. As far as I know, I have not added anything like Retrolambda to my project.

Here is my app.gradle file:

apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.myfirm.rocketchatdemo" minSdkVersion 23 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', { exclude group: 'com.android.support', module: 'support-annotations' }) // RocketChat SDK compile('com.rocketchat.core:rocketchat-core:0.7.1') { exclude group: 'org.json', module: 'json' } // https://mvnrepository.com/artifact/io.reactivex.rxjava2/rxandroid // Reactive Java compile group: 'io.reactivex.rxjava2', name: 'rxandroid', version: '2.0.1' compile 'io.reactivex.rxjava2:rxjava:2.1.1' // Chat Kit // compile 'com.github.stfalcon:chatkit:0.2.2' // ChatMessageView compile 'com.github.bassaer:chatmessageview:1.3.5' // Google Firebase compile 'com.google.firebase:firebase-core:11.4.2' // this line must be included to integrate with Firebase compile 'com.google.firebase:firebase-messaging:11.4.2' } 

This is incredibly confusing to me, either both should work or neither! In addition, my app does not function properly anymore, and I thought that maybe some residual Java 8 code might be the cause of this. That's how I stumbled on this.

Have I maybe missed some configuration to properly convert my app to SDK 23?

0

1 Answer 1

4

According to the Supported Java 8 Language Features and APIs documentation Lambda expressions do not require a certain minSdkVersion version.

This also applies to:

  • Lambda expressions
  • Method References
  • Type Annotations (compile time only)
  • Default and static interface methods
  • Repeating annotations
Sign up to request clarification or add additional context in comments.

1 Comment

Oh well alright then. Kinda interested to know how that works, but this answers my question :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.