According to methods.com play-service-base
has a total of 15k methods. However, I've already included Android support-v4
(~9k methods) in my build.gradle
. Is there anyway to make sure that the total method counts in my app is 15k instead of 24k = 15k + 9k?
My build.grade:
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
androidTestCompile('com.android.support.test:runner:0.5') {}
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') {
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
exclude module: 'support-annotations'
}
androidTestCompile 'com.android.support:support-annotations:23.4.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
transitive = true;
}
compile('com.android.support:appcompat-v7:23.4.0') {
force true
}
compile('com.android.support:support-v4:23.4.0') {
force = true;
}
compile('com.android.support:recyclerview-v7:23.4.0') {
force = true;
}
compile('com.android.support:cardview-v7:23.4.0') {
force = true;
}
compile('com.android.support:design:23.4.0') {
force = true;
}
apt 'com.jakewharton:butterknife-compiler:8.2.1'
compile 'com.android.support:percent:23.4.0'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.google.android.gms:play-services-base:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
...
}
...
Method counts are not strictly additive like that. The 64k method limit is a limit on the number of entries in the method_id_item list in the dex file. This is a list of unique method ids (class name + method name + parameters + return type) that are referenced anywhere in the dex file. So any methods that are referenced from both libraries will be de-duplicated in the final dex file, and the total method count contributed by both will be somewhat less than the 15k + 9k from the individual libraries.