I read from the wiki that Jadx should be supported on Android > API 26 and I want to integrate it into my Android Studio project.
I encounter this error when I tried to run the apk. The code snippet is converted from the wiki page as well
val jadxArgs = JadxArgs()
jadxArgs.setInputFile(File("/storage/emulated/0/Android/data/<package name>/files/classes.dex"))
jadxArgs.outDir = File("/storage/emulated/0/Android/data/<package name>/files/output")
try {
JadxDecompiler(jadxArgs).use { jadx ->
jadx.load()
jadx.save()
for (cls in jadx.getClasses()) {
for (mth in cls.getMethods()) {
Log.v("conversion", "method " + mth.name)
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
Relevant log output or stacktrace
06-26 15:15:39.139 6528 6528 D AndroidRuntime: Shutting down VM
06-26 15:15:39.139 6528 6528 E AndroidRuntime: FATAL EXCEPTION: main
06-26 15:15:39.139 6528 6528 E AndroidRuntime: Process: <package name redacted>, PID: 6528
06-26 15:15:39.139 6528 6528 E AndroidRuntime: java.lang.ExceptionInInitializerError
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at jadx.core.utils.files.FileUtils.expandDirs(FileUtils.java:52)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at jadx.api.JadxDecompiler.loadInputFiles(JadxDecompiler.java:148)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at jadx.api.JadxDecompiler.load(JadxDecompiler.java:119)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at <package.name.redacted>.MainActivity.onCreate(MainActivity.kt:140)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8051)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8031)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7839)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: Caused by: jadx.core.utils.exceptions.JadxRuntimeException: Failed to create temp root directory
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at jadx.core.utils.files.FileUtils.createTempRootDir(FileUtils.java:167)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at jadx.core.utils.files.FileUtils.<clinit>(FileUtils.java:153)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: ... 20 more
06-26 15:15:39.139 6528 6528 E AndroidRuntime: Caused by: java.nio.file.NoSuchFileException: /data/user/0/<package name redacted>/cache/jadx-instance-6586490984325279364
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:391)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at java.nio.file.Files.createDirectory(Files.java:674)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at java.nio.file.TempFileHelper.create(TempFileHelper.java:136)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at java.nio.file.TempFileHelper.createTempDirectory(TempFileHelper.java:173)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at java.nio.file.Files.createTempDirectory(Files.java:991)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: at jadx.core.utils.files.FileUtils.createTempRootDir(FileUtils.java:162)
06-26 15:15:39.139 6528 6528 E AndroidRuntime: ... 21 more
Provide sample and class/method full name
I tested this on an Android Emulator running Android OS version 12. I have granted these permissions in my AndroidManifest.xml file
Interesting, reminds me of https://github.com/skylot/jadx/issues/2131. Note that the root cause might be entirely unrelated, but in both cases Files#createTempDirectory seems to be problematic
Issue details
Hi
I read from the wiki that Jadx should be supported on Android > API 26 and I want to integrate it into my Android Studio project.
I encounter this error when I tried to run the apk. The code snippet is converted from the wiki page as well
Relevant log output or stacktrace
Provide sample and class/method full name
I tested this on an Android Emulator running Android OS version 12. I have granted these permissions in my AndroidManifest.xml file
Jadx version
jadx-core:1.5.0