I want to build my app with more classes.dex file in one apk. So I follow instruction of google help page. It is ok for android 5.0, But i cannot build for phone prior to Android 5.0. it always report:com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded. I don't know hot to build. My build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
//buildToolsVersion "20"
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.android.ccbtest.first"
minSdkVersion 21
targetSdkVersion 21
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
}
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex' // enable multidex
// optional
// dx.additionalParameters += "--main-dex list=$projectDir/<filename>".toString() // enable the main-dex-list
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/ccbtest.jar')
compile files('libs/ccbtest1.jar')
compile files('libs/ccbtest2.jar')
compile files('libs/ccbtest3.jar')
compile files('libs/ccbtest4.jar')
compile files('libs/ccbtest5.jar')
compile files('libs/ccbtest6.jar')
// Multi-dex Lib
compile 'com.android.support:multidex:1.0.0'
}
if i modify minSdkVersion 21 from 21 to 20. It will fail.
I want to in phone prior to android 5.0. Please help me about this.
thanks.
br
mwt
.