【问题标题】:android gms big method count. How to avoid it?android gms 大方法计数。如何避免?
【发布时间】:2017-02-22 16:18:51
【问题描述】:

我愿意 - 与许多开发人员一样,都存在臭名昭著的 android 65000 方法限制问题。我已经对我的应用进行了多 dexing,但我真的很想以某种方式使它更轻。

这是我的应用方法的图表(使用 dexcount 插件拍摄:https://github.com/KeepSafe/dexcount-gradle-plugin)。

如您所见,大多数方法都来自 com.google.android.gms 包。这是 build.gradle 文件中的依赖项列表:

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
    }
}

现在,我知道这些依赖关系并不多,但我不明白具体是哪一个 - 以及如何 - 触发了对 com.google.android.gms.internal.games 等包的依赖,而我的应用程序不是游戏,com.google.android.gms.internal.cast 或 com.google.android.gms.internal.fitness。而且 - 最重要的是 - 我怎样才能摆脱这些依赖关系?

非常感谢 马可

【问题讨论】:

标签: java android methods dependencies google-play-services


【解决方案1】:

要了解某些依赖项的来源,请在您的应用模块上运行 dependencies Gradle 任务。假设您应用的模块名为app,那么命令将如下所示:

./gradlew -q :app:dependencies

输出应该包含所有传递依赖,并且应该很容易看出哪些库正在拖动您想要摆脱的东西。

【讨论】:

  • 谢谢 egor,这帮了大忙!
猜你喜欢
  • 2020-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-19
  • 1970-01-01
  • 2010-12-13
  • 1970-01-01
相关资源
最近更新 更多