I have the source code of an apk, containing a few hundred classes. I need to get the list of all calls to Android SDK methods in my source code. I thought about developing a python script to parse all sources, but there seem to be too many rules to define. I fell it would be too complicated.
Does anyone has an idea ? Or are there existing tools that can do it ?
For exemple, if the code looks like this :
class MyActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
if (savedInstanceState.containsKey("toto")) {
setContentView(R.layout.mylayout);
this.uselessMethod();
}
}
public int uselessMethod() {
new Thread();
}
}
I want to get something like this :
Thanks.
Look at Doxygen for extract out all of the methods. You'll probably want to use EXTRACT_ALL http://www.doxygen.nl/manual/starting.html#extract_all which will assume everything in your sources should be documented (like third-party methods).
I was working from memory and just tried it over here. I thought Doxygen did it with additional options (see: how to get doxygen to produce call & caller graphs for c functions). While with Graphviz/dot, Doxygen does generate a collaboration diagram, it doesn't look like it will extract out what you are looking for, which I think is to list out all of the method calls, including those that aren't in your source tree.
This one worked for me:
static void printMethods(Class cls)
{
if(cls!=null){
System.out.println();
System.out.println("Printing Methods of "+cls.getName()+":");
System.out.println();
for(Method m:cls.getDeclaredMethods()){
System.out.println(m.toString());
}
}
}
How to call it:
printMethods(Class_Goes_Here);
Example:
printMethods(java.lang.Boolean.class);
Result:
Printing Methods of java.lang.Boolean:
public static int java.lang.Boolean.compare(boolean,boolean)
public static boolean java.lang.Boolean.getBoolean(java.lang.String)
public static int java.lang.Boolean.hashCode(boolean)
public static boolean java.lang.Boolean.logicalAnd(boolean,boolean)
public static boolean java.lang.Boolean.logicalOr(boolean,boolean)
public static boolean java.lang.Boolean.logicalXor(boolean,boolean)
public static boolean java.lang.Boolean.parseBoolean(java.lang.String)
public static java.lang.String java.lang.Boolean.toString(boolean)
public static java.lang.Boolean java.lang.Boolean.valueOf(java.lang.String)
public static java.lang.Boolean java.lang.Boolean.valueOf(boolean)
public boolean java.lang.Boolean.booleanValue()
public int java.lang.Boolean.compareTo(java.lang.Boolean)
public int java.lang.Boolean.compareTo(java.lang.Object)
public boolean java.lang.Boolean.equals(java.lang.Object)
public int java.lang.Boolean.hashCode()
public java.lang.String java.lang.Boolean.toString()
Lemme know if you have any further Questions or Doubts
— DiLDoST
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With