Reputation: 1899
I'm trying to use two modified Apache POI libraries. Each libray has modifications to work properly on android 4.+ and 5.+.
I need to import specific class of specific library depending on android version.
For example:
Android 4.+ versions:
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
of
compile files('libs/aa-poi-3.10-min-0.1.5.jar')
Android 5.+ versions:
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
of
compile files('libs/poi-3.12-android-a.jar')
How could i do this? Thanks
Upvotes: 1
Views: 217
Reputation: 656
Define two flavours
productFlavors {
android4plus {
minSdkVersion 14
}
android5plus {
minSdkVersion 21
}
}
Now you can setup different dependencies per flavour
android4plusCompile files('libs/aa-poi-3.10-min-0.1.5.jar')
android5plusCompile files('libs/poi-3.12-android-a.jar')
As result, you can switch between flavours during development and will have two APK files to distribute.
Upvotes: 1