You need to provide Soot either an android.jar or an rt.jar from your Java SDK on Soot's classpath. Then it should all just work.
Analyzing Android application with Soot
Domanda
I am writing some code that analyze android source code, basically to trace the definitions of local variables, and I want to use Soot in my code to extract some information from Android source code and build a high level call graph of the classes , all my work is with the java source code of the application..
I am not sure whether I need the android jars reffered to in http://www.bodden.de/2013/01/08/soot-android-instrumentation/ since the work does not involve reading or writing Dalvik bytecode - I could not download the jars anyway!!-
I am wondering if someone could give me some guidance on this, I read the mailing list of soot and tried the solutions provided but no luck- problems because of imported libraries and the R class-!![ i am testing it with a basic hello world source code]
Any help would be highly appreciated including any reference to any other tool for android static analysis..
Many thanks,,
the arguments used for the soot.Main call are:
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
argsList.addAll(Arrays.asList(new String[]{
"-allow-phantom-refs",
"-w",
"-soot-class-path",
"C:/Users/workspace_A/sootTest/src/com/example/soottest",
"-output-format",
"jimple",
"MainActivity"}
some of the results:
Warning: java.lang.NoClassDefFoundError is a phantom class!
Warning: java.lang.StringBuffer is a phantom class!
Warning: java.lang.Boolean is a phantom class!
Warning: java.lang.Long is a phantom class!
Warning: java.lang.Integer is a phantom class!
Warning: java.lang.Short is a phantom class!
Warning: java.lang.Float is a phantom class!
Warning: java.lang.Double is a phantom class!
Warning: java.lang.Throwable is a phantom class!
Warning: java.lang.Class is a phantom class!
Warning: java.lang.Character is a phantom class!
Warning: java.lang.AssertionError is a phantom class!
Warning: java.lang.Byte is a phantom class!
Warning: java.lang.Void is a phantom class!
Warning: java.lang.ClassFormatError is a phantom class!
Warning: java.lang.InstantiationError is a phantom class!
Warning: java.lang.Runnable is a phantom class!
Warning: java.lang.ref.Finalizer is a phantom class!
Warning: java.lang.IncompatibleClassChangeError is a phantom class!
Warning: java.lang.NoSuchFieldError is a phantom class!
Warning: java.lang.StackOverflowError is a phantom class!
Warning: java.lang.Thread is a phantom class!
Warning: java.lang.IllegalAccessError is a phantom class!
Warning: java.lang.ArrayStoreException is a phantom class!
Warning: java.dyn.InvokeDynamic is a phantom class!
Warning: java.lang.NoSuchMethodError is a phantom class!
Warning: java.lang.LinkageError is a phantom class!
Warning: java.lang.ExceptionInInitializerError is a phantom class!
Warning: java.lang.InternalError is a phantom class!
Warning: java.lang.VerifyError is a phantom class!
Warning: java.io.Serializable is a phantom class!
Warning: java.lang.ArrayIndexOutOfBoundsException is a phantom class!
Warning: java.lang.ClassCastException is a phantom class!
Warning: java.lang.ArithmeticException is a phantom class!
Warning: java.lang.IndexOutOfBoundsException is a phantom class!
Warning: java.lang.AbstractMethodError is a phantom class!
Warning: java.lang.Object is a phantom class!
Warning: java.lang.ThreadDeath is a phantom class!
Warning: java.lang.String is a phantom class!
Warning: java.lang.UnknownError is a phantom class!
Warning: java.lang.ClassCircularityError is a phantom class!
Warning: java.lang.Cloneable is a phantom class!
Warning: java.lang.NegativeArraySizeException is a phantom class!
Warning: java.lang.UnsatisfiedLinkError is a phantom class!
Warning: java.lang.Error is a phantom class!
Warning: java.lang.OutOfMemoryError is a phantom class!
Warning: java.lang.IllegalMonitorStateException is a phantom class!
Warning: java.lang.RuntimeException is a phantom class!
Warning: java.lang.NullPointerException is a phantom class!
Warning: java.lang.ClassNotFoundException is a phantom class!
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:3,8:
Semantic Error: no visible type named android.os.Bundle
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:4,8:
Semantic Error: no visible type named android.app.Activity
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:5,8:
Semantic Error: no visible type named android.view.Menu
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:7,35:
Semantic Error: no visible type named Activity
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:9:
Semantic Error: method does not override a method from its superclass
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:10,26:
Semantic Error: no visible type named Bundle
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:12:
Semantic Error: no method named setContentView(Unknown) in com.example.soottest.MainActivity matches.
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:12,18:
Semantic Error: R.layout not found
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:12,27:
Semantic Error: no field named activity_main
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:15:
Semantic Error: method does not override a method from its superclass
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:16,37:
Semantic Error: no visible type named Menu
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:18:
Semantic Error: no method named getMenuInflater() in com.example.soottest.MainActivity matches.
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:18,29:
Semantic Error: R.menu not found
C:\Users\workspace_A\sootTest\src\com\example\soottest\MainActivity.java:18,36:
Semantic Error: no field named main
Exception in thread "main" soot.CompilationDeathException: there were errors during parsing and/or type checking (JastAdd frontend)
at soot.JastAddInitialResolver.formAst(JastAddInitialResolver.java:63)
at soot.JavaClassSource.resolve(JavaClassSource.java:54)
at soot.SootResolver.bringToHierarchy(SootResolver.java:215)
at soot.SootResolver.bringToSignatures(SootResolver.java:239)
at soot.SootResolver.bringToBodies(SootResolver.java:280)
at soot.SootResolver.processResolveWorklist(SootResolver.java:150)
at soot.SootResolver.resolveClass(SootResolver.java:124)
at soot.Scene.loadClass(Scene.java:448)
at soot.Scene.loadClassAndSupport(Scene.java:433)
at soot.Scene.loadNecessaryClass(Scene.java:1053)
at soot.Scene.loadNecessaryClasses(Scene.java:1067)
at soot.Main.run(Main.java:167)
at soot.Main.main(Main.java:141)
at sootCFG.CallGraphExample.main(CallGraphExample.java:60)
Nessuna soluzione corretta
Altri suggerimenti