Android 统计apk中方法的数量

Posted 徐昊Xiho

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android 统计apk中方法的数量相关的知识,希望对你有一定的参考价值。

大家都知道android有65535方法数的问题,那我们有什么办法能查看我们App的这个值已经有多少了呢?

这里利用一个jar来查看点击下载工具

如何使用?

把下载下来的jar放到一个目录,比如我放在桌面上,使用以下命令:

# cd Desktop
//在执行以下命令
# java -jar C:\\Users\\uuxuh\\Desktop\\dex-method-counts.jar C:\\Users\\uuxuh\\Desktop\\SunmiWelcome_v2.1.9_uat.apk

接着回车执行,输出的信息如下:

Processing C:\\Users\\uuxuh\\Desktop\\SunmiWelcome_v2.1.9_uat.apk
Read in 19542 method IDs.
<root>: 19542
    <default>: 1
    android: 11235
        accessibilityservice: 6
        animation: 22
        app: 178
            backup: 1
        appwidget: 2
        content: 208
            pm: 17
            res: 45
        database: 36
            sqlite: 9
        graphics: 218
            drawable: 75
                shapes: 1
            pdf: 3
        hardware: 14
            display: 3
            fingerprint: 11
        media: 182
            browse: 17
            session: 87
        net: 64
            http: 4
            wifi: 25
        os: 192
        print: 23
            pdf: 5
        provider: 18
        speech: 6
            tts: 6
        support: 8955
            annotation: 20
            v4: 8935
                accessibilityservice: 41
                animation: 62
                app: 1617
                content: 293
                    pm: 1
                    res: 20
                database: 3
                graphics: 316
                    drawable: 261
                hardware: 85
                    display: 19
                    fingerprint: 66
                internal: 11
                    view: 11
                media: 1463
                    session: 818
                net: 64
                os: 68
                print: 84
                provider: 96
                speech: 14
                    tts: 14
                text: 103
                util: 283
                view: 2936
                    accessibility: 1116
                    animation: 29
                widget: 1395
        telephony: 4
        text: 14
            method: 2
            style: 1
        transition: 17
        util: 31
        view: 729
            accessibility: 211
            animation: 39
            inputmethod: 2
        webkit: 14
        widget: 302
    com: 4203
        google: 977
            appengine: 13
                api: 13
                    urlfetch: 13
            gson: 964
                annotations: 6
                internal: 561
                    bind: 292
                reflect: 18
                stream: 90
        makeramen: 126
            roundedimageview: 126
        squareup: 2171
            okhttp: 1642
                internal: 1111
                    http: 236
                    huc: 271
                    spdy: 410
                    tls: 18
            picasso: 529
        tencent: 929
            bugly: 929
                crashreport: 492
                    biz: 62
                    common: 130
                        info: 108
                        strategy: 22
                    crash: 233
                        anr: 40
                        h5: 12
                        jni: 82
                    inner: 5
                proguard: 376
    java: 1059
        io: 150
        lang: 369
            annotation: 1
            ref: 5
            reflect: 44
        math: 8
        net: 128
        nio: 33
            charset: 4
            file: 2
        security: 29
            cert: 15
            spec: 1
        sql: 3
        text: 19
        util: 320
            concurrent: 50
                atomic: 9
                locks: 2
            logging: 5
            regex: 12
            zip: 46
    javax: 36
        crypto: 13
            spec: 3
        net: 22
            ssl: 20
        security: 1
            auth: 1
                x500: 1
    okio: 381
    org: 804
        apache: 793
            commons: 649
                codec: 649
                    binary: 143
                    digest: 93
                    language: 310
                        bm: 162
                    net: 80
            http: 144
                client: 3
                    methods: 2
                entity: 124
                    mime: 123
                        content: 57
                impl: 1
                    client: 1
                message: 1
                params: 3
                util: 5
        json: 6
        xmlpull: 5
            v1: 5
    retrofit: 474
        android: 7
        appengine: 7
        client: 57
        converter: 15
        http: 23
        mime: 60
    rx: 7
        subscriptions: 1
    sunmi: 676
        sunmiui: 676
            banner: 121
            button: 33
            dialog: 149
            edit: 41
            list: 18
            refreshlistview: 80
            title: 40
            utils: 12
            view: 23
            viewgraoup: 114
            window: 5
    woyou: 664
        welcome: 664
            bean: 49
            controller: 12
            model: 7
            service: 17
            ui: 396
                activity: 230
                adapter: 23
                component: 70
                dialog: 73
            utils: 104
            wifi: 59
Overall method count: 19542

可以清楚的看到我们的总方法数为:Read in 19542 method IDs.

具体在某一个包的使用情况也能查看清楚~

以上是关于Android 统计apk中方法的数量的主要内容,如果未能解决你的问题,请参考以下文章

Android项目控件统计(XML标签统计)

Android项目控件统计(XML标签统计)

利用MySQL统计一列中不同值的数量方法示例

Android 方法数 65k 限制与 LinearAlloc 限制

如何从增加版本号的 Android Studio 中导出 apk

热门前沿知识相关面试问题-android插件化面试问题讲解