My codebase makes use of some Java 8 syntax like lambdas and has been working fine for the longest time.
Recently, my instrumented tests in a module stopped working with the infamous message:
AGPBI: {"kind":"error","text":"Invoke-customs are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
This is a known problem (there are many questions referencing it), but I have Java 1.8 in my compileOptions
:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
This problem ONLY shows up in the instrumented tests (i.e. androidTest). It's fine with unit tests and with the app itself. I already commented out all tests from the instrumented tests, but the problem persists.
My unit tests and Android tests have the same dependencies. I converted to AndroidX tests, but the issue persists.
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
androidTestImplementation 'org.mockito:mockito-core:2.27.0'
androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.ext:truth:1.1.0'
androidTestImplementation 'com.google.truth:truth:0.42'
testImplementation 'org.mockito:mockito-core:2.27.0'
testImplementation 'androidx.test:core:1.1.0'
testImplementation 'androidx.test:runner:1.1.1'
testImplementation 'androidx.test:rules:1.1.1'
testImplementation 'androidx.test.ext:junit:1.1.0'
testImplementation 'androidx.test.ext:truth:1.1.0'
testImplementation 'com.google.truth:truth:0.42'
}
I'm using the latest compile and target versions (I also tried 26 and 27) and also build tools. The min SDK version is 14, and should be.
compileSdkVersion 28
buildToolsVersion '29.0.0 rc3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
}
This is a bug in Android Studio 3.5 beta. I filed a bug with the Android Studio team, and this will be fixed with the Android Studio 3.5 beta 03 build tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With