Giter Site home page Giter Site logo

dex-method-counts's People

Contributors

almozavr avatar brianduff avatar dmide avatar dvoiss avatar eartle avatar foddermk avatar friederbluemle avatar jaredrummler avatar mihaip avatar nisrulz avatar ryanramchandar avatar sschuberth avatar who avatar yeling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dex-method-counts's Issues

can't find dex-method-counts.jar

I git clone this repo to my computer. I enter dex-method-counts/ folder and execute ./dex-method-counts /path/to/my.apk in linux shell and get an error says "can't find dex-method-counts.jar".

What I did wrong? How to solve it and get right output?

Counting in decompiled APK

Can you make it possible to count inside decompiled APK, so I can easly see if i have reached the limit or not when working with smali without having to recompile?

Add Windows instructions

Windows doesn't support the runfile you provided. You can make a .bat file, or provide the different code for Windows:

java -jar [path-to-generated-jar (./build/jar/....)] [filename to inspect]

support of *.aar

Will it be possible to teach tool to work with AAR packages?! This is actually ZIP with JAR inside... so its not exactly the DEX...

but gradle execute special step - preDexLibraries, that actually produce a DEX... so i think its possible to count methods inside AAR in two steps.

Count total number of classes of dex file

Hello, is there any way to count total of classes on dex file,
its on dalvik.system.DexFile package, but must load inside android, if possible to count it outside of android itself

Methods of Android package also included in my JAR for dexcount

Hi i have a JAR which is a library that i have developed for Android devices. I convert the JAR into dex and then run the script. But in my JAR, why are the method counts for android and JAVA packages are involved? These methods are native android and JAVA methods and they don't ship into my JAR. So why are these included for the dex count?

android: 650
        animation: 10
        app: 47
        content: 93
            pm: 11
            res: 4
        database: 18
            sqlite: 8
        graphics: 58
            drawable: 8
        location: 20
        media: 20
        net: 20
            wifi: 8
        os: 38
        provider: 3
        support: 23
            v4: 15
                view: 15
            v7: 8
                widget: 8
        telephony: 41
            cdma: 3
            gsm: 3
        text: 1
        util: 15
        view: 101
            accessibility: 2
            animation: 10
        webkit: 50
        widget: 92
   .........
   .........

    java: 381
        io: 36
        lang: 145
            ref: 3
            reflect: 8
        math: 1
        net: 25
        nio: 4
        security: 9
            spec: 1
        text: 5
        util: 156
            concurrent: 37
                atomic: 8
            zip: 1
    javax: 17
        crypto: 14
            spec: 3
        xml: 3
            parsers: 3
    org: 61
        json: 50
        w3c: 10
            dom: 10
        xml: 1
            sax: 1

Overall method count: 6163

Update DEX file magic

https://github.com/mihaip/dex-method-counts/blob/master/src/com/android/dexdeps/DexData.java#L571-L572

static class HeaderItem {
  public static final byte[] DEX_FILE_MAGIC = { 0x64, 0x65, 0x78, 0x0a, 0x30, 0x33 }; // , 0x??, 0x00 };
}

private static boolean verifyMagic(byte[] magic) {
  return Arrays.equals(Arrays.copyOfRange(magic,0,HeaderItem.DEX_FILE_MAGIC.length), HeaderItem.DEX_FILE_MAGIC)
  && magic[HeaderItem.DEX_FILE_MAGIC.length] >= 0x30
  && magic[HeaderItem.DEX_FILE_MAGIC.length+1] == 0x00;
}

Support "quiet" or "simple" mode

Would be great to have a switch that enables a mode which prints only the total method count. I've added this functionality in my fork but it constitutes some rather reaching changes to the code base that I'm not sure fit the pattern you're currently using.

write to the log

The output information is too long,How to write it to the log?

MultiDex / ART support

It doesn't appear that the script supports builds that result in multiple dex files, where classes are segmented into a primary dex file and additional dex files. The script reports only 22K methods, which I believe to be merely the methods from the primary dex (mostly our own application minus libraries.)

The Android tool chain will generate multiple DEX files when your minSdkLevel is Lollipop / 21 since that is how ART deals with library code (one dex per dependency), and also when you have the multidex switch enabled.

Support for Instant Run APK

Google release Android Studio 2.0 to Stable Channel today, as well as its instant run features. I believe dex-method-counts count the methods incorrectly for APK produced with instant run. If you try to extract the APK, you could see there is a new file instant-run.zip which contains all dexes for each package. I believe this is the reason why dex-method-counts won't work.

Any plan to support this? Thanks.

"Overall method count " does't meet the sum of all packages

$ dex-method-counts --max-depth=1 classes.dex
Processing classes.dex
Read in 64203 method IDs.
<root>: 64203
    <default>: 1
    android: 9104
    anet: 380
    anetwork: 450
    com: 23416
    dalvik: 13
    java: 1621
    javax: 45
    mtopsdk: 706
    org: 526
    tv: 29
Overall method count: 64203

when I plus each package together, the result is 36290(9104 + 380 + ...+ 29), but the overall method count is 64203. why?

Allow outputting valid yaml

It would be nice if it was possible to easily use the output of this tool for other scripts, that would for example compare binary versions to find regressions.

Yaml seems to be a good candidate as it is already quite similar to the current output. It could be essentially changing the output from

Read in 65490 method IDs.
<root>: 65490
    <default>: 3
    android: 6837
        accessibilityservice: 6
        bluetooth: 2
        content: 248
            pm: 22
            res: 45
        ...
    com: 53881
        adjust: 283
            sdk: 283
        codebutler: 65
            android_websockets: 65
        ...
    Overall method count: 65490

To something like

---
<root>: 
    <default>: 65490
    android: 
        <default>: 6837
        accessibilityservice: 6
        bluetooth: 2
        content: 
            <default>: 248
            pm: 22
            res: 45
        ...
    com:
        <default>: 53881
        adjust: 
            <default>: 283
            sdk: 283
        codebutler:
            <default>: 65
            android_websockets: 65
        ...

The totals aren't as prominent as in the current format so maybe just make it an option instead of the default format?

Automate the process.

Is it possible to automate this process on every debug build by creating custom gradle task?

UnsupportedClassVersionError while running dex-method-counts with my apk.

Exception in thread "main" java.lang.UnsupportedClassVersionError: info/persistent/dex/Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: info.persistent.dex.Main. Program will exit.

Project failed to build, can I still use?

Hi, my project has failed to build due to too many methods, can I use this tool to pinpoint the culprit? I'm not sure how to run it given I don't have an APK file, thanks!

how to get methods name

i can get method count,is there anyway to dump methods name?
btw,some classes's method-count are different to javap's.

Cannot use dex-method-counts via a symlink

I created a symlink of dex-method-counts into a directory that was in my $PATH so that I could execute it easily.

However, I found that this does not work; if you execute dex-method-counts via a symlink, it can't find the jar.

I have a fix for this that I've tested on Ubuntu and OS X, and will file a PR shortly.

Recursive

I wanted to count number of classes directly in a application java folder but the library didn't search in sub-folder and stop on the first folder with a java.io.FileNotFoundException (is a directoy) which is true but I'm stuck with that :/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.