Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default or static interface method used without --min-sdk-version >= 24

Tags:

android

java-8

Why do we get this error in Android Studio 3.0 RC1?

 com.android.dx.cf.code.SimException: 
default or static interface method used without --min-sdk-version >= 24

According to the android docs, the feature "Default and static interface methods" is compatible with Any min-sdk version.

I tracked this down to a java-library that calls Comparator.naturalOrder() - which has been added in API level 24.
So I would not expect any error-message at all for this code in a java-library.

When I use the code in my own android-app or lib java code, I see the correct lint message: "Call requires API level 24)"

Is the error-message wrong or am I missing something?

like image 605
TmTron Avatar asked Oct 15 '17 11:10

TmTron


People also ask

How do I change SDK to minSdkVersion?

To change Android minSdkVersion in Flutter for the project created after the 2.8 update, you have to make changes in the local. properties file and then reference the new variable from the local. properties file inside the build. gradle file.


2 Answers

I just found out that it works as expected when I activate the D8 dexer which is planned to be the default for Android Studio 3.1

In the project gradle.properties, add:

android.enableD8=true

Now the code compiles as expected and I still get the expected linter messages.

like image 124
TmTron Avatar answered Oct 25 '22 22:10

TmTron


If the java-library that you're talking about was guava, you can try to upgrade it to the latest android-specific build

implementation 'com.google.guava:guava:23.0-android'

This fixed for me

like image 45
Diego Plentz Avatar answered Oct 25 '22 23:10

Diego Plentz