0

I am developing a future open source Android library with Kotlin, and I'd like to count the methods from my own code as well as from dependencies. Since how Kotlin differs from Java, I assume the tool should take an aar input as a file to get the real methods count, but I only found tools taking apk files as inputs so far.

How can I do it the simplest way?

Thanks for your help!

Jayson Minard
  • 84,842
  • 38
  • 184
  • 227
Louis CAD
  • 10,965
  • 2
  • 39
  • 58
  • Check this out, they have a plug-in: http://methodscount.com/. Counting methods in jar/aar looks incorrect to me, because after `dx` number of them may change. – Miha_x64 Jun 07 '17 at 13:32
  • Possible duplicate of [Is there a way to get count of number methods used in a jar file](https://stackoverflow.com/questions/14023397/is-there-a-way-to-get-count-of-number-methods-used-in-a-jar-file) – glee8e Jun 07 '17 at 14:23

1 Answers1

2

The dexcount-gradle-plugin works with libraries as well. The resulting @aar file should not differ when using Kotlin instead of Java, since Kotlin just compiles to Java byte code as well. So just use it and you'll get all the information you need for your library.

buildscript {
    dependencies {
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.4'
    }
}
apply plugin: 'com.getkeepsafe.dexcount'
tynn
  • 38,113
  • 8
  • 108
  • 143