FlowDroid icon indicating copy to clipboard operation
FlowDroid copied to clipboard

None of the basic classes could be loaded! Check your Soot class path! Error

Open m-alex17 opened this issue 4 years ago • 6 comments

Hello, I have configured FlowDroid accordingly:

InfoflowConfiguration.CallgraphAlgorithm cgAlgorithm = InfoflowConfiguration.CallgraphAlgorithm.SPARK;
        final InfoflowAndroidConfiguration config = AndroidUtil.getFlowDroidConfig(apkPath, androidJar, cgAlgorithm);
        config.getAnalysisFileConfig().setAndroidPlatformDir(androidJar);
        config.setCodeEliminationMode(InfoflowConfiguration.CodeEliminationMode.NoCodeElimination);
        config.setCallgraphAlgorithm(cgAlgorithm); 
        SetupApplication app = new SetupApplication(config);
        app.getConfig().setMergeDexFiles(true);
        app.constructCallgraph();
        CallGraph callGraph = Scene.v().getCallGraph();

and have provided android-platforms as androidJar. Here is getFlowDroidConfig:

public static InfoflowAndroidConfiguration getFlowDroidConfig(String apkPath, String androidJar, InfoflowConfiguration.CallgraphAlgorithm cgAlgorithm) {
        final InfoflowAndroidConfiguration config = new InfoflowAndroidConfiguration();
        config.getAnalysisFileConfig().setTargetAPKFile(apkPath);
        config.getAnalysisFileConfig().setAndroidPlatformDir(androidJar);
        config.setCodeEliminationMode(InfoflowConfiguration.CodeEliminationMode.NoCodeElimination);
        config.setEnableReflection(true);
        config.setMergeDexFiles(true);
        config.setCallgraphAlgorithm(cgAlgorithm);
        return config;
    }

When I ran the program, it threw following exception:

java.lang.RuntimeException: None of the basic classes could be loaded! Check your Soot class path!
	at soot.Scene.loadBasicClasses(Scene.java:1755)
	at soot.Scene.loadNecessaryClasses(Scene.java:1845)
	at soot.jimple.infoflow.android.SetupApplication.initializeSoot(SetupApplication.java:1202)
	at soot.jimple.infoflow.android.SetupApplication.runInfoflow(SetupApplication.java:1456)
	at soot.jimple.infoflow.android.SetupApplication.constructCallgraph(SetupApplication.java:1328)

Can someone point out where I did wrong? (I built the call graph on the following app: this)

m-alex17 avatar Oct 27 '21 17:10 m-alex17

Any help?

m-alex17 avatar Feb 05 '22 15:02 m-alex17

Are you sure that your Android platform directory is correct? It must point to the platforms directory inside your Android SDK.

If that's not the problem, please post your entire console output.

StevenArzt avatar Feb 07 '22 08:02 StevenArzt

Yes, platform is correct. Here is the output:

[main] INFO soot.jimple.infoflow.android.SetupApplication - Initializing Soot...
[main] INFO soot.jimple.infoflow.android.SetupApplication - Loading dex files...
[main] ERROR soot.jimple.infoflow.android.SetupApplication - Could not construct callgraph
java.lang.RuntimeException: None of the basic classes could be loaded! Check your Soot class path!
	at soot.Scene.loadBasicClasses(Scene.java:1755)
	at soot.Scene.loadNecessaryClasses(Scene.java:1845)
	at soot.jimple.infoflow.android.SetupApplication.initializeSoot(SetupApplication.java:1202)
	at soot.jimple.infoflow.android.SetupApplication.runInfoflow(SetupApplication.java:1456)
	at soot.jimple.infoflow.android.SetupApplication.constructCallgraph(SetupApplication.java:1328)
	at Main.main(Main.java:156)
Exception in thread "main" java.lang.RuntimeException: None of the basic classes could be loaded! Check your Soot class path!
	at soot.Scene.loadBasicClasses(Scene.java:1755)
	at soot.Scene.loadNecessaryClasses(Scene.java:1845)
	at soot.jimple.infoflow.android.SetupApplication.initializeSoot(SetupApplication.java:1202)
	at soot.jimple.infoflow.android.SetupApplication.runInfoflow(SetupApplication.java:1456)
	at soot.jimple.infoflow.android.SetupApplication.constructCallgraph(SetupApplication.java:1328)
	at Main.main(Main.java:156)

My platform is from version 3 to 17. I added 29 and 30. Note that I have considered a separate path(folder) just for these and point to it as android jar(as it's in my above code).

m-alex17 avatar Feb 07 '22 09:02 m-alex17

The platfom directory must contain subdirectories for the individual platform JARs. So you keep the original folder structure from the Android SDK? You may not point to an invidual JAR, you have to use the platforms directory.

You can also try to set a breakpoint in Scene.defaultAndroidClassPath() and see whether the computed classpath makes sense.

StevenArzt avatar Feb 07 '22 10:02 StevenArzt

The platfom directory must contain subdirectories for the individual platform JARs. So you keep the original folder structure from the Android SDK? You may not point to an invidual JAR, you have to use the platforms directory.

You can also try to set a breakpoint in Scene.defaultAndroidClassPath() and see whether the computed classpath makes sense.

I keep them in a directory named "android-platforms" and there are subdirectories for each version containing Jar file related to them. By the way the program crash for this app not all the apps I've tried to work on them. Thank you. I'll try your advice.

m-alex17 avatar Feb 07 '22 12:02 m-alex17

Fixed it by downloading android-platforms from here.

m-alex17 avatar Feb 07 '22 13:02 m-alex17