B
B
boristhecat2021-04-14 11:00:14
Java
boristhecat, 2021-04-14 11:00:14

How to determine if a library/dependency is compatible with devices whose SDK version is equal to {minSdkVersion}?

How to determine if a library/dependency is compatible with devices whose SDK version is equal to {minSdkVersion}?
For example, in Java 8 there are things that cannot be used if the minSdkVersion of your Android application is, for example, 16 (Stream API, StandardCharsets class, String.join() method, etc.). For the sake of interest, I tried to make a simple library, connect it to my project and run it on an emulator with API 22 (I was too lazy to download 16). Her code:

import java.util.Arrays;

public final class Library {
    private Library() {
    }

    public static void crash() {
        Arrays.stream(new int[]{1, 2, 3}).close();
    }
}

Calling the crash() method, as expected, got an error:
java.lang.NoSuchMethodError: No static method stream([I)Ljava/util/stream/IntStream; in class Ljava/util/Arrays; or its super classes (declaration of 'java.util.Arrays' appears in /system/framework/core-libart.jar)

Now to the question.
There is a library originally written in Java 8. My project's minSdkVersion is 16. Is there a way to make sure this library will work on older androids?
If so, sorry. I'm new to Android, you might say.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question