【问题标题】:IBM MobileFirst 7 dependenciesIBM MobileFirst 7 依赖项
【发布时间】:2023-03-11 19:45:01
【问题描述】:

我正在将 MobileFirst 7 库用于本机 Android 应用程序,但发现它严重增加了我的 Android 应用程序的 dex 方法计数(将其推过65,536 limit)。

根据Adding the IBM MobileFirst Platform Foundation SDK to a new or existing application with Android Studio 的文章,我在build.gradle 中添加了以下内容:

compile group: 'com.ibm.mobile.foundation',
        name: 'ibmmobilefirstplatformfoundation',
        version: '7.1.0.0',
        ext: 'aar',
        transitive: true

根据methodscount.com,MobileFirst 库(及其依赖项)引入了多达 39,364 个方法(占可用 dex 方法计数的 60%)!

我认为 Proguard 可能有助于减少使用 MobileFirst 的影响,但发现示例 proguard-project.txt 具有以下指令:

-keep class com.google.** { *;}

据我了解,这有效地告诉 Proguard 不要删除任何 Google Guava 方法。 MobileFirst 还引入了其他库,但我从 Guava 开始,因为它是最大的。

然后我决定调查 MobileFirst 使用 Guava 库的情况:

$ unzip ibmmobilefirstplatformfoundation-7.1.0.aar
$ jadx --output-dir temp/ classes.jar
$ grep -roh . -e 'com.google.common.*' | sort | uniq

哪个发现对任何 Guava 库的引用为零(允许反编译器可能缺少某些引用),但似乎可以排除 Guava 依赖项?

compile(group: 'com.ibm.mobile.foundation',
        name: 'ibmmobilefirstplatformfoundation',
        version: '7.1.0.0',
        ext: 'aar',
        transitive: true) {
    exclude group: 'com.google.guava', module: 'guava'
}

如果不是这样(排除番石榴会是个问题),那么:

  • 是否有更好的 Proguard 规则可用于仅保留 MobileFirst 依赖项中必需的方法?
  • 是否也可以排除 MobileFirst 依赖的其他大型库?

【问题讨论】:

    标签: android ibm-mobilefirst proguard


    【解决方案1】:

    如果您没有使用 JSONStore 功能,您可以安全地排除以下内容:

    • guava.jar
    • commons-codec.jar
    • 杰克逊-*

    【讨论】:

    • 谢谢!这有很大帮助!任何 org.bouncycastle.* 都可以被排除(因为它是下一个大依赖项)?我相信它是在 MobileFirst 具有的“org.bouncycastle:bcprov-jdk15on:1.48”依赖项下引入的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-05
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多