Is it possible to create a different app version for each android version?

Asked

Viewed 57 times

3

It has components that are not supported in previous versions of android, but has alternatives to them. Has some way to maintain ideal components for the ideal versions and alternatives for those versions that do not support it?

  • 1

    I believe that there is no way to do it in a simple way, maybe you have to create different projects, containing the codes you want for each android version. The simplest is to use the 2 codes and separate them in the versions you want to consider in each one. To do this create a Utility class and in the key points, perform the validation: public static boolean isAndroidMarshmallowOrSuperiorVersion() {
 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
 }

1 answer

3

It is possible, even if it is creating a project for each version.

The main problem with this approach is code repetition.,

This problem can be avoided using another approach: Build variants.

Build variants are achieved by using Gradle’s ability to use specific rules to define code combinations, resources, and configurations to generate different builds of the same project.

The possibilities are several, of which I highlight the following:

References:

Note: As support libraries solve most of the cases you refer to without the need to resort to compilation variants.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.