【问题标题】:Why does the dex methods count add 3 when I add one method?为什么我添加一个方法时dex方法计数加3?
【发布时间】:2016-03-14 03:18:23
【问题描述】:

我添加一个方法

public static void cancelAll(RequestQueue queue,@NonNull final Object tag){
        queue.cancelAll(new RequestQueue.RequestFilter() {
            @Override
            public boolean apply(Request<?> request) {

                Object oldTag = request.getTag();
                if(tag == null || oldTag == null){
                    return false;
                }
                if(oldTag instanceof Integer && tag instanceof Integer){
                    return (int)oldTag == (int)tag;
                }else if(oldTag instanceof String && tag instanceof String){
                    return ((String) tag).equalsIgnoreCase((String)oldTag);
                }
                return false;
            }
        });
    }

并且dex方法计数加3。

我认为他们是cancelAll和apply。第三个在哪里?

BuildType 是 release。我使用 proguard。

当我将 buildType 设置为 debug 时也是如此。

【问题讨论】:

    标签: android-proguard android-multidex


    【解决方案1】:

    您引用的 dex 方法计数指定在单个 dex 中引用的方法总数,而不仅仅是 声明的方法!
    因此,您的问题不能轻易回答。

    为什么不使用 dextra 等工具转储所有方法名称,无论是否使用此方法,然后对输出进行比较?
    例如:

    ./dextra -M classes.dex
    

    将输出所有引用的method_ids列表,格式如下:

    Method (0): <init>  Access Flags: 0x0    Params: () Returns: V
    Method (1): attachBaseContext   Access Flags: 0x0    Params: (Landroid/content/Context;)    Returns: V
    Method (2): getClassLoader  Access Flags: 0x0    Params: () Returns: Ljava/lang/ClassLoader;
    ...
    

    【讨论】:

    • 有空我会试试的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多