我需要集成 Google Play Services Analytics 库,但它为我的应用程序贡献了 28k 个方法!我被迫使用 multidex,但为了保持应用程序的大小,我不希望使用 multidex。鉴于 Android 支持库贡献了 18k,仅仅为 Analytics 贡献 28k 有点疯狂,不是吗?还有其他方法可以减少此方法计数的膨胀吗?
以下是我放入 build.gradle 中的依赖项:
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.+'
compile 'com.adjust.sdk:adjust-android:4.1.2'
我正在使用这些工具来计算方法计数: https://gist.github.com/JakeWharton/6002797
它向我显示 com.google 包正在贡献 28901 个方法。
最佳答案
如果不使用 multidex,您的另一个选择是删除您不与 Proguard 一起使用的部分库。
关于android - 集成Google Play服务分析库后减少应用程序的方法数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33551896/