Skip to content

java.lang.NoClassDefFoundError on calling constructCallGraph() in an android application, #836

@Harshit22209

Description

@Harshit22209

Running FlowDroid in an APK, crashes when SetupApplication.constructCallgraph() initializes FlowDroidMemoryWatcher. The watcher delegates to MemoryWarningSystem, which requires java.lang.management.ManagementFactory (JMX).

I think the reason for this is:
Android’s runtime does not provide java.lang.management.*, so class loading fails with NoClassDefFoundError.

Am i correct ?

val setup = SetupApplication(androidJar, apkFile)
 val cfg = setup.config  
 cfg.callbackConfig.setEnableCallbacks(false)   
setup.constructCallgraph() 

Soot/FlowDroid failed
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/management/ManagementFactory;
at soot.jimple.infoflow.memory.MemoryWarningSystem.findTenuredGenPool(MemoryWarningSystem.java:156)
at soot.jimple.infoflow.memory.MemoryWarningSystem.(MemoryWarningSystem.java:63)
at soot.jimple.infoflow.memory.FlowDroidMemoryWatcher.(FlowDroidMemoryWatcher.java:22)
at soot.jimple.infoflow.AbstractInfoflow.runAnalysis(AbstractInfoflow.java:834)
at soot.jimple.infoflow.AbstractInfoflow.runAnalysis(AbstractInfoflow.java:808)
at soot.jimple.infoflow.android.SetupApplication$InPlaceInfoflow.runAnalysis(SetupApplication.java:1358)
at soot.jimple.infoflow.android.SetupApplication.processEntryPoint(SetupApplication.java:1656)
at soot.jimple.infoflow.android.SetupApplication.runInfoflow(SetupApplication.java:1585)
at soot.jimple.infoflow.android.SetupApplication.constructCallgraph(SetupApplication.java:1439)
at com.example.malwaredetector.SootAnalyzeRunner.analyzeFile(SootAnalyzeRunner.kt:150)
at com.example.malwaredetector.runner.SootRunnerService.onStartCommand$lambda$3(SootRunnerService.kt:95)
at com.example.malwaredetector.runner.SootRunnerService.$r8$lambda$J76wxW3_qPnsEJ7phes8d5844Rw(Unknown Source:0)
at com.example.malwaredetector.runner.SootRunnerService$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.management.ManagementFactory" on path: DexPathList[[dex file "/data/data/com.example.malwaredetector/code_cache/.overlay/base.apk/classes4.dex", zip file "/data/app/~~K85R8B4ik7KNnnbBQ9dCsA==/com.example.malwaredetector-dbTnueby37flV8cGI5LzDg==/base.apk"],nativeLibraryDirectories=[/data/app/~~K85R8B4ik7KNnnbBQ9dCsA==/com.example.malwaredetector-dbTnueby37flV8cGI5LzDg==/lib/arm64, /data/app/~~K85R8B4ik7KNnnbBQ9dCsA==/com.example.malwaredetector-dbTnueby37flV8cGI5LzDg==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)

Since i am using kotlin version, i am assuming FlowDroid is supported in an APK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions