Unfortunately, since you must include the dependency, it will always be compiled into your project.
You can split your project into separate projects. If you created something like BaseApp and IceCreamSandwichApp , you could set different minSdkVersions for each along with a different set of dependencies.
Thus, you must have modules in your application:
your-app/BaseApp
and
your-app/IceCreamSandwichApp
And your gradle files look something like this:
your-app / settings.gradle
include ':BaseApp', ':GingerbreadApp'
your-app / BaseApp / build.gradle
android { buildToolsVersion '22.0.1' defaultConfig { minSdkVersion 9 compileSdkVersion 21 targetSdkVersion 21 } ... dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } }
your-app / IceCreamSandwichApp / build.gradle
android { buildToolsVersion '22.0.1' defaultConfig { minSdkVersion 14 compileSdkVersion 21 targetSdkVersion 21 } ... dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(":BaseApp") compile 'the.third.party:lib:here:1.0.0' } }
source share