Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set max sdk version on build.gradle

How set the android max sdk version on build.gradle at android studio.

I want do an app with two flavor, the first will run between version x~y and the second run at y+

Before on eclipse, in AndroidManifest.xml we have android:maxSdkVersion="y" but how it works on gradle?

like image 475
ademar111190 Avatar asked Oct 29 '25 22:10

ademar111190


2 Answers

You cannot set the maxSdkVersion in gradle. Actually, it is discourage by Google because of several issues. The main issue is that Google Play could decide to remove an app from a user device during an update if the system doesn't meet the maxSdkVersion specified in the app. For example, imagine you have a device with API Level 12 and you install an app with android:maxSdkVersion="12", then later you receive a system update that upgrades your android version to API Level 13...Google Play will uninstall your app.

Basically, you don't need this setting and you can easily ignore it, use the targetSDkVersion attribute and the minSdkVersion.

  1. For your app "in flavour 1" with "version x~y" set the minSdkversion to x and the targetSdkVersion to y
  2. now, for the app "in flavour 2", you will need to make sure that the sdk version don't get overlapped by the app "in flavour 1", set the min sdk version to "z". Otherwise, users with a device with api level "y" will never get to see this app in Google Play
like image 139
Leo Avatar answered Nov 01 '25 13:11

Leo


Please note this.

Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation. Google Play will continue to use the attribute as a filter, however, when presenting users with applications available for download.

https://developer.android.com/guide/topics/manifest/uses-sdk-element.html

like image 37
Isham Avatar answered Nov 01 '25 11:11

Isham