This question answers your question. It shows how to build a project with any minimum SDK, while maintaining a minimum SDK for Lint alerts.
To summarize the message, you can dynamically calculate the minSdkVersion value:
int minSdk = hasProperty('devMinSdk') ? devMinSdk.toInteger() : 15 apply plugin: 'com.android.application' android { ... defaultConfig { minSdkVersion minSdk ... } }
In this example, we check if the devMinSdk property is devMinSdk , and if true, we use it. Otherwise, we will be 15 by default.
How to pass devMinSdk value for build script? Two options:
Using the command line:
./gradlew installDebug -PdevMinSdk=21
Using Android Studio settings:
Go to the "Settings" section in Windows) → "Build, -PdevMinSdk=21 , Deploy → Compiler → put -PdevMinSdk=21 in the" Command Line Parameters text box.

source share