简体   繁体   中英

android gms big method count. How to avoid it?

I do - as many developers, have issues with the infamous android 65000 methods limit. I'm already multi-dexing my app but I'd really like to make it lighter somehow.

This is the graph of my app's methods (taken with dexcount plugin: https://github.com/KeepSafe/dexcount-gradle-plugin ).

在此处输入图片说明

As you can see, most of the methods come from the com.google.android.gms package. This is the list of dependencies from build.gradle file:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    compile project(':libs:cip-library:cip-library')
    compile project(':libs:android-times-square')
    compile files('../libs/mobile.connect-android-1.7.6.jar')
    compile files('../libs/dtapl-2.1.1.jar')
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
    compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'de.greenrobot:greendao:2.0.0'
    compile 'com.pnikosis:materialish-progress:1.5'
    compile 'org.adw.library:discrete-seekbar:1.0.0'
    compile 'com.android.support:design:24.2.1'
    compile 'net.fredericosilva:showTipsView:1.0.4'
    compile 'com.google.maps.android:android-maps-utils:0.4.4'
    compile 'com.robohorse.gpversionchecker:gpversionchecker:1.0.8'
    compile 'net.danlew:android.joda:2.9.4.1'
    compile 'com.android.support:support-annotations:24.2.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
        transitive = true;
    }
    compile('com.mikepenz:aboutlibraries:5.7.1@aar') {
        transitive = true
    }
}

Now, I know these dependencies are not a few, but what I don't understand is specifically which one - and how - is triggering the dependency on packages like com.google.android.gms.internal.games, while my app is not a game, com.google.android.gms.internal.cast or com.google.android.gms.internal.fitness. And - most of all - how could I ever get rid of those dependencies?

Thank you very much Marco

To understand where certain dependencies come from, run the dependencies Gradle task on your app's module. Suppose your app's module is called app , then the command will look like:

./gradlew -q :app:dependencies

The output should contain all transitive dependencies, and it should be easy to see which libraries are dragging the stuff that you want to get rid of.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM